-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculate-total-number-coins.cpp
More file actions
64 lines (43 loc) · 1.63 KB
/
Calculate-total-number-coins.cpp
File metadata and controls
64 lines (43 loc) · 1.63 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//Homework for lesson 4
//Purpose: A program that calculates the total value of a number of coins
//Author: Larsen J Close Most recent changes: 2/12/2016
#include <iostream> // preprocessor directive
#include <iomanip> // needed for most manipulators
#include <cmath> // needed for sqrt()
using namespace std; // using directive
int main ( void )
{
double h; //h for half dollars
double q; //q for quarters
double d; //d for dimes
double n; //n for nickles
double p; //p for pennies
double t; //total value
cout << "This program calculates the total";
cout << "value of a number of coins." << endl;
cout << "Enter the number of half dollars: ";
cin >> h ;
cout << "Enter the number of quarters : ";
cin >> q ;
cout << "Enter the number of dimes : ";
cin >> d ;
cout << "Enter the number of nickles : ";
cin >> n ;
cout << "Enter the number of pennies : ";
cin >> p ;
t = (h*0.5) + (q*0.25) + (d*0.1) + (n*0.05) + (p*0.01);
cout << fixed << setprecision(2);
cout << "Total value = $" << t << endl;
system ("pause");
return 0;
} //end main ( )
/* Display for above program
This program calculates the totalvalue of a number of coins.
Enter the number of half dollars: 1
Enter the number of quarters : 4
Enter the number of dimes : 5
Enter the number of nickles : 2
Enter the number of pennies : 3
Total value = $2.13
Press any key to continue . . .
*/