Embed
Email

Topic 1 Code Examples

Document Sample

Categories
Tags
Stats
views:
0
posted:
11/15/2011
language:
English
pages:
2
/**************************************Topic 1, Example 1*******************************/

//Topic 1, Example 1

//Program prompts user to enter total number of inches

//Program converts user-entered number of inches to

// yards/feet/inches

//Program will output the resulting converted values



#include

const int YARD = 36;

const int FEET = 12;



int main( )

{

int totalInches = 0; //stores user-entered value

int yards = 0; //stores converted inches to yards

int feet = 0; //stores converted inches to feet

int inches = 0; //stores converted remaining inches



cout > totalInches; //stores user-entered value



yards = totalInches / YARD; //calculate number of yards

feet = (totalInches % YARD) / FEET; //calculate number of feet

inches = (totalInches % YARD) % FEET; //calculate number of inches



cout



int main( )

{

double hoursWorked = 0; //stores total hours worked

double payPerHour = 0; //stores hourly pay rate

double salary = 0; //stores calculated salary



cout > hoursWorked; //store user input



cout > payPerHour; //store user input



salary = hoursWorked * payPerHour; //calculate salary



cout

#include //header for formatting output



int main( )

{

double hoursWorked = 0; //stores total hours worked

double payPerHour = 0; //stores hourly pay rate

double salary = 0; //stores calculated salary



cout > hoursWorked; //store user input



cout > payPerHour; //store user input



salary = hoursWorked * payPerHour; //calculate salary



cout << "\nThe salary for " //program output

<< hoursWorked << " hour(s) worked at a rate of $"

<< payPerHour << " per hour is $" << salary << ".";

cout << endl << endl;

return(0);

}



Related docs
Other docs by Stariya Js @ B...
Lab2_Fishing_lab_pack
Views: 0  |  Downloads: 0
JMK sample legal brief
Views: 1  |  Downloads: 0
DriveQ
Views: 0  |  Downloads: 0
cybersecurity_reform_-_senate_bill_eyes
Views: 0  |  Downloads: 0
Opening and Marketing
Views: 0  |  Downloads: 0
Making_it_Work_notes
Views: 0  |  Downloads: 0
First Announcement 7th ISFS_
Views: 0  |  Downloads: 0
as90173
Views: 0  |  Downloads: 0
VNAfashionshow2010
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!