|
That would be helpful....But I have this assignment and I have no idea where to go from here...
Assignment
CS 115 Programming Assignment 2
Fall 2007
Due Date: Tuesday 9 Oct 2007 - by Midnight
This PA is a variation on PP 3 in Ch 4 on parameters and overloading.
It is also an extension of our PA 1.
You will do the following to PA 1:
Create a function called ReadRoundedAmount that sends back to the function main both the original amount read from the keyboard, and that amount converted to pennies and rounded to the nearest penny.
Create the function named ConputeCoin that is described in the book.
Create a function named WriteChange that writes a line of output that looks as follows:
$37.79 = 37 dollars, 3 quarters, 0 dimes, 0 nickles, 4 pennies.
This function should have parameters that enable it to be called by the function main.
Use a loop in function main that calls these functions at the right time, in the right order, as often as the user provides input that is not zero. The main function should declare any variables that are needed to call the functions and initialize any as needed.
Hint: start with a copy of PA 1. Add each new function one at a time and move some code from function main to the new function. Test that the program still works as before. Finally, add a loop to execute repeatedly until the user enters a zero.
If done correctly, this program will cleanly separate input, calculation, output, and control in the various functions that it containes
What I have done.....
#include <iostream>
int main()
{
using std::cout;
using std::endl;
using std::cin;
double output;
int intOutput;
cout << "Enter dollar amount: ";
while (!(cin >> output))
{
cin.clear();
while (cin.get() != '\n') {}
cout << "as a double: ";
}
intOutput = (int) (100 * output + 0.5);
cout << "$" << output << " = ";
cout << intOutput / 100 << " dollars, "
<< ( intOutput % 100) / 25 << " quarters, "
<< ((( intOutput % 100) % 25) / 10 ) << " dimes, "
<< ((( intOutput % 100) % 25) % 10 ) / 5 << " nickles, "
<< ((( intOutput % 100) % 25) % 10 ) % 5 << " pennies.";
return 0;
}
Anyone can help me please do so because I am lost from here
__________________
Ill play tug of war with your life line
|