Hey guys, I have an assignment in which it requires me to add up how many quarters, dimes, nickels, and pennies I have. Now my problem is that how could I make it like if I put "3" when it asks me how many quarters, it would read it as 75 cents? same for the rest. In the prompt its asking me to find a way to add all these test data and the result would be $1.23 Sorry for my english
Test Data: 3 quarters, no dimes, 5 nickels, and 23 pennies
Can someone help me create a code which if I put 3 quarters, the system would translate it to 75. Same for nickels, if I put 5 nickels, it would translate it into 25. So in over all if I input 3 quarters, 5 nickels, and 23 pennies, it should add up to 1.23
#include <iostream>
usingnamespace std;
int main()
{
//Declare Variables
int quarters;
int dimes;
int nickels;
int pennies;
float Z;
//Input Variables
cout << "How much quarters do you have?";
cin >> quarters;
cout << "How much dimes do you have?";
cin >> dimes;
cout << "How much nickels do you have?";
cin >> nickels;
cout << "How much pennies do you have?";
cin >> pennies;
//Compute
Z = (quarters + dimes + nickels + pennies);
//Output
cout << Z;
system("pause");
return 0;
}
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
//constant
//[Constants are expressions with a fixed value.]
constdouble qtrs = 0.25;
constdouble dm = 0.10;
constdouble nckl = 0.05;
constdouble pn = 0.01;
int main()
{
//Declare Variables
int quarters;
int dimes;
int nickels;
int pennies;
double z;
//Input Variables
cout << "How much quarters do you have?";
cin >> quarters;
cout << "How much dimes do you have?";
cin >> dimes;
cout << "How much nickels do you have?";
cin >> nickels;
cout << "How much pennies do you have?";
cin >> pennies;
//Compute
z = (quarters * qtrs) + (dimes * dm) + (nickels * nckl) + (pennies * pn);
//Output
cout<<endl<<z;
return 0;
}