summaryrefslogtreecommitdiffstats
path: root/C++/NewSummerJob/NewSummerJob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'C++/NewSummerJob/NewSummerJob.cpp')
-rw-r--r--C++/NewSummerJob/NewSummerJob.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/C++/NewSummerJob/NewSummerJob.cpp b/C++/NewSummerJob/NewSummerJob.cpp
new file mode 100644
index 0000000..a88aadc
--- /dev/null
+++ b/C++/NewSummerJob/NewSummerJob.cpp
@@ -0,0 +1,84 @@
+// Name: msglm
+// Introduction: Summer Job Wage Calculator
+// Description: a program that calculates a weekly wage, based on an hourly payrate and how many hours were worked; then calculates amounts for various categories of spending, along with how much of the weekly pay is leftover.
+
+
+#include <iostream>
+#include <string>
+#include <iomanip>
+using namespace std;
+const double tax = 0.15;
+int main() {
+ //Rounding gets a bit gross when using floats, at the cost of memory, doubles are used.
+ string name;
+ double payRate;
+ double hours;
+ double WeeklyWage;
+ double shoppingPercent;
+ double entertainmentPercent;
+ double savingsPercent;
+ double remainder;
+
+ //Program Information
+ cout << "Name: Summer Job Wage Calculator \n";
+ cout << "Description: a program that calculates a weekly wage, based on an hourly payrate and how many hours were worked; then calculates amounts for various categories of spending, along with how much of the weekly pay is leftover.\n\n";
+
+ //Accept input via cin for hourly wages, pay rate, and name
+
+ //getline already in use, no need to change
+ cout << "What is your full name?: ";
+ getline(cin, name);
+
+ cout << "What is your payrate (per hour)?: ";
+ cin >> payRate;
+
+ cout << "How many hours have you worked?: ";
+ cin >> hours;
+
+ //Get the percentage variables
+
+ cout << "\n===NOTE: The following prompts do not need percentage symbols===\n";
+
+ cout << "How much would you like to allocate to shopping?\n";
+ cin >> shoppingPercent;
+
+ cout << "How much would you like to allocate to savings?\n";
+ cin >> savingsPercent;
+
+ cout << "How much would you like to allocate to entertainment?\n";
+ cin >> entertainmentPercent;
+
+ //Convert the input to percentages
+ shoppingPercent = shoppingPercent/100;
+ entertainmentPercent = entertainmentPercent/100;
+ savingsPercent = savingsPercent/100;
+
+
+ //Multiply the input to create the WeeklyWage variable
+ //Possible memory optimization here by removing the WeeklyWage variable, but at the cost of CPU cycles.
+ WeeklyWage = hours*payRate;
+
+ //Remainder will be its own var due to the more complex way to calculate it
+ remainder = WeeklyWage - WeeklyWage*(shoppingPercent+entertainmentPercent+savingsPercent+tax);
+
+ //have a bunch of cout statements that do all the math
+ // I.e : cout << “Tax: “ << WeeklyWage*tax
+
+ cout << fixed << setprecision(2);
+ cout << setw(15) << "Name:" << right << setw(5+name.length()) << name << endl;
+ cout << setw(15) << "Wages:" << right << setw(6) << "$" << WeeklyWage*tax << endl;
+ cout << setw(15) << "shopping:" << right << setw(6) << "$" << WeeklyWage*shoppingPercent << endl;
+ cout << setw(15) << "entertainment:" << right << setw(6) << "$" << WeeklyWage*entertainmentPercent << endl;
+ cout << setw(15) << "savings:" << right << setw(6) << "$" << WeeklyWage*savingsPercent << endl;
+ cout << setw(15) << "remainder:" << right << setw(6) << "$" << remainder << 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/>.
+ */
+