I did some work on coins value. I got most working but last part at line 34 and 48. I realize i ran out of idea what to put in or how math work. I need value to work out as $5.30 something like that. I'm sorry, my math is my worse.
#include "std_lib_facilities.h"
int main()
{
cout << "How many pennies do you have?\n";
cout << "\n";
int cents;
int pennies;
int nickels;
int dimes;
int quarters;
int dollars;
double value;
cin >> cents;
pennies = cents;
nickels = cents / 5;
dimes = cents / 10;
quarters = cents / 25;
dollars = cents / 100;
value = cents / 100.0;
cout << "\n";
cout << "Aha you have " << cents << " cents right now\n";
cout << "Aha you have " << nickels << " nickels right now\n";
cout << "Aha you have " << dimes << " dimes right now\n";
cout << "Aha you have " << quarters << " quarters right now\n";
cout << "Aha you have " << dollars << " dollars right now\n";
cout << "Your value is $" << value << ".";
}
If you want to have a variable that can handle decimals, you should declare it as float or double.
Then, the value that you put in this variable can not be an integer, but fortunately if you do a calculation with an integer and a double, the result will be a double.
So, you should declare:
double value;
and the calculation should be
value = cents / 100.0;
And a minor side note, because memory is limited the accuracy of decimal numbers in your program is limited. As a result if you have a double value and you perform a calculation with another double value, the result might be a bit off.
Therefor, if you are doing calculations with things like money, it is often best to convert all values to the smallest possible unit (in this case cents), calculate with that and only convert the result to a value with decimals. You already did this here, but just in case it was not on purpose I wanted to mention it anyway.