-
Notifications
You must be signed in to change notification settings - Fork 0
/
moneyNotesCalculator.cpp
46 lines (37 loc) · 1.08 KB
/
moneyNotesCalculator.cpp
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
#include <iostream>
using namespace std;
int main() {
int tk, notesOf100 = 0, notesOf50 = 0, notesOf20 = 0, notesOf1 = 0;
cout << "Enter the amount of money: " << endl;
cin >> tk;
while (tk >= 1) {
if (tk >= 100) {
int notes = tk / 100;
notesOf100 = notes;
int currentMoney = tk - (notesOf100 * 100);
tk = currentMoney;
}
else if (tk >= 50) {
int notes = tk / 50;
notesOf50 = notes;
int currentMoney = tk - (notesOf50 * 50);
tk = currentMoney;
}
else if (tk >= 20) {
int notes = tk / 20;
notesOf20 = notes;
int currentMoney = tk - (notesOf20 * 20);
tk = currentMoney;
}
else if (tk >= 1) {
int notes = tk / 1;
notesOf1 = notes;
int currentMoney = tk - (notesOf1 * 1);
tk = currentMoney;
}
}
notesOf100 > 0 && cout << "Notes of 100: " << notesOf100 << endl;
notesOf50 > 0 && cout << "Notes of 50: " << notesOf50 << endl;
notesOf20 > 0 && cout << "Notes of 20: " << notesOf20 << endl;
notesOf1 >> 0 && cout << "Notes of 1: " << notesOf1 << endl;
}