summaryrefslogtreecommitdiffstats
path: root/C++/Test1
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
committermsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
commit9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch)
treeeb1efc1d028b949dd83bb710c68be8eff58f26e7 /C++/Test1
downloadschool-code-master.tar.gz
school-code-master.tar.bz2
school-code-master.zip
Inital CommitHEADmaster
Diffstat (limited to 'C++/Test1')
-rw-r--r--C++/Test1/BookStoreReceipt.cpp58
-rw-r--r--C++/Test1/ErrorCorrection.cpp66
2 files changed, 124 insertions, 0 deletions
diff --git a/C++/Test1/BookStoreReceipt.cpp b/C++/Test1/BookStoreReceipt.cpp
new file mode 100644
index 0000000..ef6d903
--- /dev/null
+++ b/C++/Test1/BookStoreReceipt.cpp
@@ -0,0 +1,58 @@
+// Name: msglm
+// Date: Feb-14-2022
+// Program Name: Bookstore Receipt Program
+// Description: a program that will calculate the price (plus tax) of a book store recieipt
+
+
+#include <iostream>
+#include <string>
+#include <iomanip>
+using namespace std;
+
+// Named constants
+double const TAX = 0.0964;
+double const BOOKPRICE = 5.00;
+double const COPYPRICE = 1.10;
+double const PENPRICE = 1.15;
+double const FOLDERPRICE = 1.00;
+
+int main() {
+
+ //Variable declaration
+ int book, copy, pen, folder;
+ double total;
+
+ //Program title and description for the user
+ cout << "Title: Bookstore Receipt Program" << endl << "Description: a program that will calculate the price (plus tax) of a book store recieipt" << endl;
+
+ // User input
+ cout << "How many books would you like?\n";
+ cin >> book;
+ cout << "How many packs of copy paper would you like?\n";
+ cin >> copy;
+ cout << "How many packs of pens would you like?\n";
+ cin >> pen;
+ cout << "How many folder packs would you like?\n";
+ cin >> folder;
+ // Calculations for the total price (Without Tax)
+ total = (book*BOOKPRICE + copy*COPYPRICE + pen*PENPRICE + folder*FOLDERPRICE);
+ // Output to the screen
+ cout << "Receipt: \n";
+ cout << "Books: $" << book*BOOKPRICE << endl;
+ cout << "Packs of Copy Paper: $" << copy*COPYPRICE << endl;
+ cout << "Packs of Pens: $" << pen*PENPRICE << endl;
+ cout << "Packs of Folders: $" << folder*FOLDERPRICE << endl;
+ cout << "Total (Without Tax): $" << total << endl;
+ cout << "Total Tax: $" << total*TAX << endl;
+ cout << "Total (With Tax): $" << total+(total*TAX) << endl;
+
+
+ return 0;
+}
+
+/*This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
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;
+}