//Ashton Dreiling
//Money exercise
#include <iostream>
#include <stdlib.h>
using namespace std;
//Module prototypes
void calculateTheValueOfPensNicksDimesQuarts (int pennies, int nickles,
int dimes, int quaters, int &valueOfPennies,
int &valueOfNickles, int &valueOfDimes, int &valueOfQuarters);
//Global constants that will be used to calculate the total amount the user has after they input values
const int costOfPenny = .01;
const int costOfNickle = .05;
const int costOfDime = .10;
const int costOfQuarter = .25;
const int aDollar = 1.00;
int main()
{
//some variables to hold money values
int pennies;
int nickles;
int dimes;
int quarters;
int valueOfPennies;
int valueOfNickles;
int valueOfDimes;
int valueOfQuarters;
int total;
cout << "Hello, the point of this program is to make no more than one dollar. Let's see if you can do it." << endl;
cout << "Please enter the number of pennies you have." << endl;
cin >> pennies;
cout << "You said you had " << pennies << endl;
cout << "Please enter the number of nickles you have." << endl;
cin >> nickles;
cout << "You said you had " << nickles << endl;
cout << "Please enter the number of dimes you have." << endl;
cin >> dimes;
cout << "You said you had " << dimes << endl;
cout << "Please enter the number of quarters you have." << endl;
cin >> quarters;
cout << "You said you had " << quarters << endl;
cout << "We will now calculate if you made a dollar or went over a dollar." << endl;
//passvariables to calculateTheValueOfPensNicksDimesQuarts
calculateTheValueOfPensNicksDimesQuarts (pennies, nickles, dimes,
quarters, valueOfPennies, valueOfNickles,
valueOfDimes, valueOfQuarters);
//final amount to compare in an if-then statement to see if they went over a dollar of if they met exactly one dollar
total = valueOfPennies + valueOfNickles + valueOfDimes + valueOfQuarters;
cout << "Your total is " << total << endl;
if (total == aDollar)
cout << "Congratulations! You did it!" << endl;
else
{
if (total < aDollar)
cout << "Sorry, you had less than a dollar" << endl;
else
{
if (total > aDollar)
cout << "Sorry, you went over a dollar." << endl;
}
return 0;
system("Pause");
}//end main
void calculateTheValueOfPensNicksDimesQuarts(int pennies, int nickles, int dimes, int quarters,
int &valueOfPennies, int &valueOfNickles, int &valueOfDimes,
int &valueOfQuarters)
{
valueOfPennies = pennies * costOfPenny;
valueOfNickles = nickles * costOfNickle;
valueOfDimes = dimes * costOfDime;
valueOfQuarters = quarters * costOfQuarter;
}//end of calculateTheValueOfPensNicksDimesQuarts module
Ah I must have messed something up again : (
http://prntscr.com/bjejj7
These are the error I'm getting now
You're helping a lot! I changed the data type and put the parameters on different lines. That's all I did.