summaryrefslogtreecommitdiffstats
path: root/C++/Test1/ErrorCorrection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'C++/Test1/ErrorCorrection.cpp')
-rw-r--r--C++/Test1/ErrorCorrection.cpp66
1 files changed, 66 insertions, 0 deletions
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 <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;
+}