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
|
// Your Name: msglm
// Date: Feb-14-2022
// Program Title: Make Change
// Program Description: Given any amount of change expressed in cents, this program
// computes the number of halh-dollars, quarters, dimes, nickels, and pennies to be
// returned, returning as many half-dollars as possible, then quarters, dimes, nickels,
// and pennies in that order.
#include <iostream>
#include <string>
//Didn't declare namespace as used
using namespace std;
// Named constants
const int HALF_DOLLAR = 50;
const int QUARTER = 25;
const int DIME = 10;
//Nickel missing int
const int NICKEL = 5;
int main()
{
// Variable declaration
int change;
//Program title and description for the user
cout << "Program Title: Make Change" << endl;
cout << "Program Description: Given any amount of change expressed in cents, this program "
<< "computes the number of half-dollars, quarters, dimes, nickels, and pennies to be "
//Missing terminating quote
<< "returned, returning as many half-dollars as possible, then quarters, dimes, nickels,"
<< "and pennies in that order." << endl << endl;
// User input
cout << "Enter change in cents: ";
//Variable capitalized; variables are case sensitive
cin >> change;
cout << endl;
cout << "The change you entered is: " << change << endl;
// Calculations and Output to the screen
cout << "The number of half-dollars to be returned is: " << change / HALF_DOLLAR << endl;
change = change % HALF_DOLLAR;
//forgot semicolon
cout << "The number of quarters to be returned is: " << change / QUARTER << endl;
change = change % QUARTER;
//Forgot extra <
cout << "The number of dimes to be returned is: " << change / DIME << endl;
//Variable/Constant names are case sensitive
change = change % DIME;
cout << "The number of nickels to be returned is: " << change / NICKEL << endl;
change = change % NICKEL;
//Forgot to place terminating end-quote
cout << "The number of pennies to be returned is: "<< change << endl;
//Never gave a return code or similar value
return 0;
}
|