@LoganDark/

# QuizzicalBetterDecimal

## No description

Files
• main.cpp
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
```
```// Charlie's bad code, not mine

#include <iostream>
#include <cmath>
using namespace std;

int main() {

int payment = 0;
string again = "y";

while (again == "y" || again == "Y") {
string order;
double price;
int dollarChange;
int quarterChange;
cout << "What would you like to order?" << endl;
cin >> order;
cout << "How much does it cost?" << endl;
cin >> price;
while (fmod(price, 0.25) != 0){
cout << "Prices have to be multiples of 25 cents." << endl;
cin >> price;
}
cout << "Your choices of payment methods are: " << endl;
cout << "1 - \$1 Cash" << endl;
cout << "2 - \$5 Cash" << endl;
cout << "3 - \$20 Cash" << endl;
cout << "4 - \$50 Cash" << endl;
cout << "5 - Appul Pay" << endl;

cout << "How would you like to pay? (1/5): ";
cin >> payment;
cout << endl;

switch (payment) {
case 1 :
if (price - 1 > 0) {
cout << order << " costs more than that." << endl;
} else {
cout << "Enjoy your " << order << endl;
dollarChange = (int)(1-price);
quarterChange = fmod(price, 0.25);
quarterChange = quarterChange - dollarChange*4 ;
cout << "Your change is " << dollarChange << " dollars and " << quarterChange << " quarters." << endl;

}
break;

case 2 :
if (price - 5 > 0) {
cout << "A(n) " << order << " costs more than that." << endl;
} else {
cout << "Enjoy your " << order << endl;
dollarChange = (int)(5-price);
quarterChange = fmod(price, 0.25);
quarterChange = quarterChange - dollarChange*4 ;
cout << "Your change is " << dollarChange << " dollars and " << quarterChange << " quarters." << endl;
}
break;
case 3 :
if (price - 20 > 0) {
cout << "A(n) " << order << " costs more than that." << endl;
} else {
cout << "Enjoy your " << order << endl;
dollarChange = (int)(20-price);
quarterChange = fmod(price, 1) /4;
cout << quarterChange - dollarChange*4 << quarterChange << dollarChange*4;
cout << "Your change is " << dollarChange << " dollars and " << quarterChange << " quarters." << endl;
}
break;
case 4 :
if (price - 50 > 0) {
cout << "A(n) " << order << " costs more than that." << endl;
} else {
cout << "Enjoy your " << order << endl;
dollarChange = (int)(50-price);
quarterChange = fmod(price, 0.25);
quarterChange = quarterChange - dollarChange*4 ;
cout << "Your change is " << dollarChange << " dollars and " << quarterChange << " quarters." << endl;
}
break;
case 5 :
cout << "... Approved. Enjoy your " << order << endl;
break;
default :
cout << "Error. Choice was not valid, Here is your money back.";

break;
}
cout << "Would you like to go again? (Y/N)" << endl;
cin >> again;
cout << endl;
}
}```
Fetching token