From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- C++/Test1/ErrorCorrection.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 C++/Test1/ErrorCorrection.cpp (limited to 'C++/Test1/ErrorCorrection.cpp') diff --git a/C++/Test1/ErrorCorrection.cpp b/C++/Test1/ErrorCorrection.cpp new file mode 100644 index 0000000..2a84c23 --- /dev/null +++ b/C++/Test1/ErrorCorrection.cpp @@ -0,0 +1,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 +#include + +//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; +} -- cgit v1.2.3