CPP
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
#include <iostream>
using namespace std;
int main() {
double price, received, back;
int hundred = 0, ten = 0, one = 0;
double half;
cout << "What's the price? ";
cin >> price;
cout << "How much did you receive? ";
cin >> received;
back = received - price;
if (back-static_cast<int>(back) > 0.75) {
one++;
half = 0;
}
else if (back-static_cast<int>(back) < 0.25) {
half = 0;
}
else {
half = 0.5;
}
if (back >= 100) {
hundred = back / 100;
back = static_cast<int>(back) % 100;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run