-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ1.1.cpp
More file actions
32 lines (31 loc) · 817 Bytes
/
Q1.1.cpp
File metadata and controls
32 lines (31 loc) · 817 Bytes
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
#include <iostream>
using namespace std;
int main() {
int amount, notes;
cout << "Enter the amount: ";
cin >> amount;
cout << "The minimum number of notes are: \n";
notes = amount / 500; // count the number of 500 notes
if (notes > 0) {
cout << "notes of \"500\" = " << notes << "\n";
amount = amount - notes * 500; // subtract the value of 500 notes
}
switch (amount) { // use switch statement for the remaining amount
case 100:
cout << "notes of \"100\" = 1\n";
break;
case 50:
cout << "notes of \"50\" = 1\n";
break;
case 20:
cout << "notes of \"20\" = 1\n";
break;
case 10:
cout << "notes of \"10\" = 1\n";
break;
default:
cout << "Invalid amount\n";
break;
}
return 0;
}