this is the question:
A third grade teacher at Hinsbrook Elementary School would like you to create a program that will help her students learn how to make change. The program should allow the student to enter the amount the customer owes and the amount of money the customer paid. The program should calculate and display the amount of change, as well as how many dollars, quarters, dimes, nickels, and pennnies to return to the customer. For now, you don't have to worrie about the situation where the price is greater than what the customer pays. You can always assume that the customer paid either the exact amount or more than the exact amount.
I need to code the program and this is what I have so far and from my conclusions my calculations or something is off for I get negative numbers as the change. Here is the code I did:
Code:
#include <iostream>
//#include "stdafx.h"
using std:: cout;
using std:: cin;
using std:: endl;
int main()
{
//declare variables
double totalamount = 0.0;
double amountdue = 0.0;
double amountpaid= 0.0;
int DOLLARS = 0.0;
int QUARTERS = 0.0;
int DIMES = 0.0;
int NICKELS = 0.0;
int PENNIES = 0.0;
//enter input items
cout << "Enter amount due: ";
cin >> amountdue;
cout << "Enter amount paid: ";
cin >> amountpaid;
//calculate change
changeamount = amountdue - amountpaid;
DOLLARS = changeamount / 1 ;
QUARTERS = (dollars * 1) /.25 ;
DIMES = (changeamount - (dollars * 1) - (quarters * .25) / .1 );
NICKELS = (changeamount - (dollars * 1) - (quarters* .25) - (dimes* .1) / .05) ;
PENNIES = (changeamount - (dollars * 1) - (quarters * .25) - (dimes * .1) - (nickels * .05)/.01) ;
//display amount due
cout << "dollars: " << Dollars << endl;
cout << "quarters: " << Quarters << endl;
cout << "dimes: " << Dimes << endl;
cout << "nickels: " << Nickels << endl;
cout << "pennies: " <<Pennies<< endl;
return 0;
//end of main function
}
can some one help me correct this coding. Thanks