HOW DO I ADD COIN VALUES?!?

How do i go about setting quarters to 25, dimes equal to 10 and nickles to 5 and pennies to 1?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <string>
#include <iostream>
using namespace std;

int main()
{
	// DECLARING THE VARIABLES
	string name;
	double saved, total, quarters, dimes, nickles, pennies, weeks;
	std::cout.precision(6);
	// Title Screen
	cout << "Welcome to the Piggy Bank Program!" << endl;
	cout << "Press Enter to Continue";
	cin.ignore();
	cout << "----------------------------------" << endl;
	cout << "Hi, can I please have your name so I can address you properly? " << endl;
	cin >> name;
	cout << "Your name is " <<name;
	cout << "? I like that name!" << endl;
	cout << "--------------------------------------------------------------" << endl;
	cout << "Okay, I am going to ask you a series of questions regarding amounts of how much you have in coins." << endl;
	cout << "--------------------------------------------------------------------------------------------------" << endl;
	cout << "How many quarters you have currently?" << endl;
	cin >> quarters;
	cout << "How many dimes do you have currently?" << endl;
	cin >> dimes;
	cout << "How many nickles do you have currently?" << endl;
	cin >> nickles;
	cout << "How many pennies do you have currently?" << endl;
	cin >> pennies;
	total = dimes + pennies + nickles + quarters;
	cout << "The grand total is:" << total << endl;
	system("pause");
	return 0;
}
Last edited on
closed account (E0p9LyTq)
total = (pennies + (nickles * 5) + (dimes * 10) + (quarters * 25)) / 100;

That gives a $x.xx total.
Topic archived. No new replies allowed.