C.I.S. 1.5

Brooklyn College

Professor Langsam

 

Assignment #1

 

Here is part of an interactive program that computes the value of some coins. The user is asked to input the number of half dollars, quarters, dimes, etc.

 
int main()
{
      int   halfDollars,      // number of half dollars
            quarters,         // number of quarters
            dimes,            // number of dimes
            nickels,          // number of nickels
            pennies,          // number of pennies
            total;            // total in pennies
      float value;            // value of coins
 
      . . . . .
    
      cout << "The value of your change will be computed." << endl;
 
      cout << "\nHow many half dollars to you have? ";
      cin >> halfDollars;
 
      cout << "\nHow may quarters do you have? ";
      cin >> quarters;
 
            . . . . .
    
Complete the program, causing it to print our relevant information as follows: 
 
You entered:      0 half dollars
                  3 quarters
                  2 dimes
                  17 nickels
                  1 pennies
 
The value of your 23 coins is $1.81 which is equivalent to 181 pennies. 

 

Use the following data:

 

Half dollars

Quarters

Dimes

Nickels

Pennies

0

3

2

17

1

2

1

5

0

0

0

0

0

5

50

1

1

1

1

1

Make up 6 additional sets of data

 

Use the trailer method to signal the end of data. Be sure to use meaningful variables. Comment your program, and use a consistent style.

 

Hint: See page 100 of the Jones and Harrow, Problem Solving with C++ text for information regarding formatting the value of your coins into dollars and cents.