-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (42 loc) · 935 Bytes
/
Copy pathmain.cpp
File metadata and controls
49 lines (42 loc) · 935 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <string>
#include <cctype>
#include "functions.h"
using namespace std;
bool isNumb(string number);
int main()
{
int penny = 1;
int nickel = 5;
int dime = 10;
int quarter = 25;
bool quit = false;
string cents;
while(!quit)
{
cout << "Please enter cents, or type 'Q' to quit: ";
cin >> cents;
if(!isNumb(cents))
{
if(cents.length() != 0)
{
if(cents[1] == 'Q' || cents[0] == 'q')
{
quit = true;
}
}
}
else
{
int totalCents = atoi(cents.c_str());
int totalQuarters = totalCents / quarter;
totalCents %= quarter;
int totalDimes = totalCents / dime;
totalCents %= dime;
int totalNickels = totalCents / nickel;
totalCents %= nickel;
int totalPennies = totalCents / penny;
cout << "Quarters: " << totalQuarters << ", Dimes: " << totalDimes << ", Nickels: " << totalNickels << ", Pennys: " << totalPennies << endl << endl;
}
}
}