aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk2
diff options
context:
space:
mode:
Diffstat (limited to 'ee1301/wk2')
-rw-r--r--ee1301/wk2/hw2_directory/strap012_HW2A.cpp96
-rw-r--r--ee1301/wk2/hw2_directory/strap012_HW2B.cpp202
-rw-r--r--ee1301/wk2/hw2_directory/strap012_HW2C.cpp96
-rw-r--r--ee1301/wk2/lab2/bmr.cpp52
-rw-r--r--ee1301/wk2/lab2/calc.cpp56
-rw-r--r--ee1301/wk2/lab2/greektax.cpp62
-rw-r--r--ee1301/wk2/lab2/specrel.cpp50
-rw-r--r--ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp100
8 files changed, 357 insertions, 357 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_HW2A.cpp b/ee1301/wk2/hw2_directory/strap012_HW2A.cpp
index 6401dbe..2877801 100644
--- a/ee1301/wk2/hw2_directory/strap012_HW2A.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_HW2A.cpp
@@ -1,49 +1,49 @@
-/*
-20 Feb 2019
-Matthew Strapp
-5449340
-EE1301
-Spring 2019
-Homework 2A
-Useless Counter
-*/
-
-#include <iostream>
-using namespace std;
-int main () {
- int countOG, i, j;
-
-do {
-
- do {
- cout << "Enter an integer from -50 to 50: ";
- cin >> countOG;
- } while (countOG > 50 || countOG < -50);
-
- int count=countOG; //Store original integer for comparison to break loop
-
- if (countOG < 0){
- count*=-1;
- for (i=count; i>0; i--) {
- for (j=count; j>0; j--) {
- cout << count;
- }
- count--;
- cout << endl;
- }
- }
-
- if (countOG > 0) {
- for (count=1; count<=countOG; count++) {
- for (i=0; i<count; i++) {
- cout << count;
- }
- cout << endl;
- }
- }
-
-} while (countOG != 0);
-
- cout << "Goodbye." << endl;
- return 0;
+/*
+20 Feb 2019
+Matthew Strapp
+5449340
+EE1301
+Spring 2019
+Homework 2A
+Useless Counter
+*/
+
+#include <iostream>
+using namespace std;
+int main () {
+ int countOG, i, j;
+
+do {
+
+ do {
+ cout << "Enter an integer from -50 to 50: ";
+ cin >> countOG;
+ } while (countOG > 50 || countOG < -50);
+
+ int count=countOG; //Store original integer for comparison to break loop
+
+ if (countOG < 0){
+ count*=-1;
+ for (i=count; i>0; i--) {
+ for (j=count; j>0; j--) {
+ cout << count;
+ }
+ count--;
+ cout << endl;
+ }
+ }
+
+ if (countOG > 0) {
+ for (count=1; count<=countOG; count++) {
+ for (i=0; i<count; i++) {
+ cout << count;
+ }
+ cout << endl;
+ }
+ }
+
+} while (countOG != 0);
+
+ cout << "Goodbye." << endl;
+ return 0;
} \ No newline at end of file
diff --git a/ee1301/wk2/hw2_directory/strap012_HW2B.cpp b/ee1301/wk2/hw2_directory/strap012_HW2B.cpp
index 6172718..fb6481f 100644
--- a/ee1301/wk2/hw2_directory/strap012_HW2B.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_HW2B.cpp
@@ -1,101 +1,101 @@
-/*
-20 Feb 2019
-Matthew Strapp
-5449340
-EE1301
-Spring 2019
-Homework 2B
-Time Travel Calculator
-*/
-
-#include <iostream>
-using namespace std;
-int main()
-{
-
- bool foo = 0, bar = false; //Workaround to prevent unneeded if statements
- char Time, travel; //"time" is reserved by C++, "Time" is not
- int hourOG, hourChange, hourNew, intervalChange = 0, timeChange = 0;
- cout << "Enter current time (A for AM, P for PM): ";
- cin >> hourOG >> Time;
- cout << "How many hours forward or backward do you want to move the clock (F for forwards, B for backward): ";
- cin >> travel >> hourChange;
- for (int i = hourChange; i >= 0; i--)
- {
- if (i != 0)
- {
- intervalChange++;
- }
- if (travel == 'F')
- {
- if (hourOG + hourChange >= 12)
- {
- if (hourOG + hourChange == 12)
- {
- timeChange++;
- }
- else //This else statement is a complete hackjob. It works consistently though.
- {
- int temp = (hourOG + hourChange) - 12;
- bar=true;
- while (temp>12) {
- temp-=12;
- timeChange++;
- }
- hourNew=temp;
- }
- }
- timeChange++;
- }
-
- if (travel == 'B')
- {
- if (hourOG - hourChange <= 0)
- {
- int temp = (hourOG - hourChange) + 12;
- bar=true;
- while (temp>12) {
- temp-=12;
- timeChange++;
- }
- if (hourChange<=24) {
- hourNew=temp;
- } else {
- for (int k=(hourChange%24); k>0; k--) {
- hourNew=temp+12;
- }
- }
- }
- timeChange++;
- }
- if (intervalChange >= 12)
- {
- intervalChange = 0;
- timeChange++;
- }
- }
- for (timeChange; timeChange > 1; timeChange--)
- {
- if (Time == 'A')
- {
- Time += 15; //15 is the difference in the ASCII table between 'A' and 'P'
- }
- else
- {
- if (Time == 'P')
- {
- Time -= 15;
- }
- }
- }
- if (travel == 'F' && !bar)
- {
- hourNew = hourOG + intervalChange;
- }
- if (travel == 'B' && !bar)
- {
- hourNew = hourOG - intervalChange;
- }
- cout << "The new time is: " << hourNew << " " << Time << "M" << endl;
- return 0;
-}
+/*
+20 Feb 2019
+Matthew Strapp
+5449340
+EE1301
+Spring 2019
+Homework 2B
+Time Travel Calculator
+*/
+
+#include <iostream>
+using namespace std;
+int main()
+{
+
+ bool foo = 0, bar = false; //Workaround to prevent unneeded if statements
+ char Time, travel; //"time" is reserved by C++, "Time" is not
+ int hourOG, hourChange, hourNew, intervalChange = 0, timeChange = 0;
+ cout << "Enter current time (A for AM, P for PM): ";
+ cin >> hourOG >> Time;
+ cout << "How many hours forward or backward do you want to move the clock (F for forwards, B for backward): ";
+ cin >> travel >> hourChange;
+ for (int i = hourChange; i >= 0; i--)
+ {
+ if (i != 0)
+ {
+ intervalChange++;
+ }
+ if (travel == 'F')
+ {
+ if (hourOG + hourChange >= 12)
+ {
+ if (hourOG + hourChange == 12)
+ {
+ timeChange++;
+ }
+ else //This else statement is a complete hackjob. It works consistently though.
+ {
+ int temp = (hourOG + hourChange) - 12;
+ bar=true;
+ while (temp>12) {
+ temp-=12;
+ timeChange++;
+ }
+ hourNew=temp;
+ }
+ }
+ timeChange++;
+ }
+
+ if (travel == 'B')
+ {
+ if (hourOG - hourChange <= 0)
+ {
+ int temp = (hourOG - hourChange) + 12;
+ bar=true;
+ while (temp>12) {
+ temp-=12;
+ timeChange++;
+ }
+ if (hourChange<=24) {
+ hourNew=temp;
+ } else {
+ for (int k=(hourChange%24); k>0; k--) {
+ hourNew=temp+12;
+ }
+ }
+ }
+ timeChange++;
+ }
+ if (intervalChange >= 12)
+ {
+ intervalChange = 0;
+ timeChange++;
+ }
+ }
+ for (timeChange; timeChange > 1; timeChange--)
+ {
+ if (Time == 'A')
+ {
+ Time += 15; //15 is the difference in the ASCII table between 'A' and 'P'
+ }
+ else
+ {
+ if (Time == 'P')
+ {
+ Time -= 15;
+ }
+ }
+ }
+ if (travel == 'F' && !bar)
+ {
+ hourNew = hourOG + intervalChange;
+ }
+ if (travel == 'B' && !bar)
+ {
+ hourNew = hourOG - intervalChange;
+ }
+ cout << "The new time is: " << hourNew << " " << Time << "M" << endl;
+ return 0;
+}
diff --git a/ee1301/wk2/hw2_directory/strap012_HW2C.cpp b/ee1301/wk2/hw2_directory/strap012_HW2C.cpp
index 6e5c432..4d3d9b3 100644
--- a/ee1301/wk2/hw2_directory/strap012_HW2C.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_HW2C.cpp
@@ -1,49 +1,49 @@
-/*
-20 Feb 2019
-Matthew Strapp
-5449340
-EE1301
-Spring 2019
-Homework 2C
-One-armed Bandit
-*/
-
-#include <iostream>
-#include <time.h>
-
-using namespace std;
-int main () {
- srand (time(NULL)); //This seeds the randomness based on the current time
- bool win=false;
- int d=0, spin1, spin2, spin3, spin4;
- do {
- do {
- win=false; //Reset win from before, otherwise win will always be true after it is true once
- cout << "How many values do you want on each wheel? ";
- cin >> d;
- } while (d==0); //Without this failsafe, the program does undefined things at d=0, usually crashing
-
- spin1= rand () % d + 1;
- spin2= rand () % d + 1;
- spin3= rand () % d + 1;
- spin4= rand () % d + 1;
- cout << "The wheels spin to give: " << spin1 << " " << spin2 << " " << spin3 << " " << spin4 << " ";
- if (spin1==spin2) { // These nested statements only let the bool "win" be true if all of the spinners match
- if (spin2==spin3) {
- if (spin3==spin4) {
- win=true;
- }
- }
- }
- if (win) {
- cout << "Eureka!";
- }
- else {
- cout << "You lose.";
-
- }
- cout << endl;
- } while (d!=-1);
- cout << "OK, goodbye." << endl;
- return 0;
+/*
+20 Feb 2019
+Matthew Strapp
+5449340
+EE1301
+Spring 2019
+Homework 2C
+One-armed Bandit
+*/
+
+#include <iostream>
+#include <time.h>
+
+using namespace std;
+int main () {
+ srand (time(NULL)); //This seeds the randomness based on the current time
+ bool win=false;
+ int d=0, spin1, spin2, spin3, spin4;
+ do {
+ do {
+ win=false; //Reset win from before, otherwise win will always be true after it is true once
+ cout << "How many values do you want on each wheel? ";
+ cin >> d;
+ } while (d==0); //Without this failsafe, the program does undefined things at d=0, usually crashing
+
+ spin1= rand () % d + 1;
+ spin2= rand () % d + 1;
+ spin3= rand () % d + 1;
+ spin4= rand () % d + 1;
+ cout << "The wheels spin to give: " << spin1 << " " << spin2 << " " << spin3 << " " << spin4 << " ";
+ if (spin1==spin2) { // These nested statements only let the bool "win" be true if all of the spinners match
+ if (spin2==spin3) {
+ if (spin3==spin4) {
+ win=true;
+ }
+ }
+ }
+ if (win) {
+ cout << "Eureka!";
+ }
+ else {
+ cout << "You lose.";
+
+ }
+ cout << endl;
+ } while (d!=-1);
+ cout << "OK, goodbye." << endl;
+ return 0;
} \ No newline at end of file
diff --git a/ee1301/wk2/lab2/bmr.cpp b/ee1301/wk2/lab2/bmr.cpp
index 26fdbae..b86c36c 100644
--- a/ee1301/wk2/lab2/bmr.cpp
+++ b/ee1301/wk2/lab2/bmr.cpp
@@ -1,26 +1,26 @@
-#include <iostream>
-using namespace std;
-
-int main () {
- int age,height,weight,chocolate;
- double BMR;
- char sex;
- cout << "Enter weight in pounds:"; cin >> weight;
- cout << "Enter height in inches:"; cin >> height;
- cout << "Enter age in years:"; cin >> age;
- cout << "Enter Sex(M/F)"; cin >> sex;
-
- if (sex=='F' || sex=='f'){
- BMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);
- cout << "Your BMR is: " << BMR;
- }
-
- if (sex=='M' || sex=='m'){
- BMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);
- cout << "Your BMR is: " << BMR;
- }
-
- chocolate = BMR/230;
- cout << endl << "Number of 230 Calories bars you can have is: " << chocolate << endl;
- return 0;
-}
+#include <iostream>
+using namespace std;
+
+int main () {
+ int age,height,weight,chocolate;
+ double BMR;
+ char sex;
+ cout << "Enter weight in pounds:"; cin >> weight;
+ cout << "Enter height in inches:"; cin >> height;
+ cout << "Enter age in years:"; cin >> age;
+ cout << "Enter Sex(M/F)"; cin >> sex;
+
+ if (sex=='F' || sex=='f'){
+ BMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);
+ cout << "Your BMR is: " << BMR;
+ }
+
+ if (sex=='M' || sex=='m'){
+ BMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);
+ cout << "Your BMR is: " << BMR;
+ }
+
+ chocolate = BMR/230;
+ cout << endl << "Number of 230 Calories bars you can have is: " << chocolate << endl;
+ return 0;
+}
diff --git a/ee1301/wk2/lab2/calc.cpp b/ee1301/wk2/lab2/calc.cpp
index f9925b0..9cb2e03 100644
--- a/ee1301/wk2/lab2/calc.cpp
+++ b/ee1301/wk2/lab2/calc.cpp
@@ -1,28 +1,28 @@
-#include <iostream>
-using namespace std;
-
-int main () {
- int a,b;
- char op;
- cout << "Enter an equation: ";
- cin >> a >> op >> b;
- cout << a << op << b << " = ";
-
- if (op=='+'){ //Addition
- cout << a + b;
- }
-
- if (op=='-'){ //Subtraction
- cout << a - b;
- }
-
- if (op=='*'){ //Multiplication
- cout << a * b;
- }
-
- if (op=='/'){ //Division
- cout << a / b;
- }
-
- cout << endl;
- }
+#include <iostream>
+using namespace std;
+
+int main () {
+ int a,b;
+ char op;
+ cout << "Enter an equation: ";
+ cin >> a >> op >> b;
+ cout << a << op << b << " = ";
+
+ if (op=='+'){ //Addition
+ cout << a + b;
+ }
+
+ if (op=='-'){ //Subtraction
+ cout << a - b;
+ }
+
+ if (op=='*'){ //Multiplication
+ cout << a * b;
+ }
+
+ if (op=='/'){ //Division
+ cout << a / b;
+ }
+
+ cout << endl;
+ }
diff --git a/ee1301/wk2/lab2/greektax.cpp b/ee1301/wk2/lab2/greektax.cpp
index c229e35..fba3918 100644
--- a/ee1301/wk2/lab2/greektax.cpp
+++ b/ee1301/wk2/lab2/greektax.cpp
@@ -1,31 +1,31 @@
-#include <iostream>
-using namespace std;
-int main () {
- int Income;
- int Tax=0;
- cout << "Enter your income: ";
- cin >> Income;
- if (Income>10000) { //Income under 10000 is not taxed
- int k10=Income-30000;
- if (k10<=0){
- Tax+=((Income-10000)*.1); //Income between 10000 and 30000 is taxed at 10%
- }
- else {
- Tax+=2000;
- }
- if (Income>30000) {
- int k30=Income-70000;
- if (k30<=0){
- Tax+=((Income-30000)*.2); //Income between 30000 and 70000 is taxed at 20%
- }
- else {
- Tax+=8000;
- }
- if (Income>70000) {
- Tax+=((Income-70000)*.3); //Income over 70000 is taxed at 30%
- }
- }
- }
- cout << "You owe " << Tax << " drachmas in tax." << endl;
-
-}
+#include <iostream>
+using namespace std;
+int main () {
+ int Income;
+ int Tax=0;
+ cout << "Enter your income: ";
+ cin >> Income;
+ if (Income>10000) { //Income under 10000 is not taxed
+ int k10=Income-30000;
+ if (k10<=0){
+ Tax+=((Income-10000)*.1); //Income between 10000 and 30000 is taxed at 10%
+ }
+ else {
+ Tax+=2000;
+ }
+ if (Income>30000) {
+ int k30=Income-70000;
+ if (k30<=0){
+ Tax+=((Income-30000)*.2); //Income between 30000 and 70000 is taxed at 20%
+ }
+ else {
+ Tax+=8000;
+ }
+ if (Income>70000) {
+ Tax+=((Income-70000)*.3); //Income over 70000 is taxed at 30%
+ }
+ }
+ }
+ cout << "You owe " << Tax << " drachmas in tax." << endl;
+
+}
diff --git a/ee1301/wk2/lab2/specrel.cpp b/ee1301/wk2/lab2/specrel.cpp
index ba95469..b925e3c 100644
--- a/ee1301/wk2/lab2/specrel.cpp
+++ b/ee1301/wk2/lab2/specrel.cpp
@@ -1,25 +1,25 @@
-/*
-Date: 13 Feb 2019
-Name: Matthew Strapp
-Student ID number: 5449340
-Course number: EE1301
-Term: Spring 2019
-Lab/assignment number: W-Up 1
-Short Program Description: Special Relativity equation tool
-*/
-
-#include <iostream>
-#include <cmath>
-using namespace std;
-
-int main () {
- double L,v,c;
- c=3e+10;
-
- cout << "Enter L: "; cin >> L;
- cout << "Enter V: "; cin >> v;
- cout << "Relative Length = " <<
- L * sqrt(1-(v*v)/(c*c)) //Relativistic Equation
- << endl;
- return 0;
-}
+/*
+Date: 13 Feb 2019
+Name: Matthew Strapp
+Student ID number: 5449340
+Course number: EE1301
+Term: Spring 2019
+Lab/assignment number: W-Up 1
+Short Program Description: Special Relativity equation tool
+*/
+
+#include <iostream>
+#include <cmath>
+using namespace std;
+
+int main () {
+ double L,v,c;
+ c=3e+10;
+
+ cout << "Enter L: "; cin >> L;
+ cout << "Enter V: "; cin >> v;
+ cout << "Relative Length = " <<
+ L * sqrt(1-(v*v)/(c*c)) //Relativistic Equation
+ << endl;
+ return 0;
+}
diff --git a/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp b/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp
index f0689d4..d87f156 100644
--- a/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp
+++ b/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp
@@ -1,50 +1,50 @@
-/*
-Date: 13 Feb 2019
-Name: Matthew Strapp
-Student ID number: 5449340
-Course number: EE1301
-Term: Spring 2019
-Lab/assignment number: Workout
-Short Program Description: Pay Stub Calculator
-*/
-
-#include <iostream>
-#include <iomanip>
-using namespace std;
-
-int main () {
- int Dependents, Hours;
- int OT = 0, Health = 0, Union =0; //Set values to zero to prevent problems
- double SocSec, State, Fed, GrossPay, NetPay;
- cout << "How many hours did you work this week?: ";
- cin >> Hours;
- if (Hours < 0) {
- cout << "Invalid option!" << endl;
- return 2;
- }
- cout << "How many dependents do you have?: ";
- cin >> Dependents;
- if (Hours > 40) { //Every hour over 40 constitutes as overtime
- OT=Hours-40;
- }
- if (Dependents >= 3 && Hours > 0) { //More than 3 dependents carries a fee
- Health=35;
- }
- GrossPay = Hours * 16.78 + OT * 16.78 * 1.5;
- SocSec = GrossPay * 0.06;
- Fed = GrossPay * 0.14;
- State = GrossPay * .05;
- if (GrossPay>0){
- Union=10;
- }
- NetPay = GrossPay - SocSec - Fed - State - Health - Union;
- cout << fixed << setprecision(2) << endl << "Your gross (before withholdings) pay is $" << GrossPay << "." << endl
- << "Social Security withholding: $" << SocSec << endl
- << "Federal income tax withholding: $" << Fed << endl
- << "State income tax withholding: $" << State << endl
- << "Union Dues: $" << Union << endl
- << "Medical cost: $" << Health << endl
-
- << "Your net (after witholdings) pay is $" << NetPay << "." << endl;
-
-}
+/*
+Date: 13 Feb 2019
+Name: Matthew Strapp
+Student ID number: 5449340
+Course number: EE1301
+Term: Spring 2019
+Lab/assignment number: Workout
+Short Program Description: Pay Stub Calculator
+*/
+
+#include <iostream>
+#include <iomanip>
+using namespace std;
+
+int main () {
+ int Dependents, Hours;
+ int OT = 0, Health = 0, Union =0; //Set values to zero to prevent problems
+ double SocSec, State, Fed, GrossPay, NetPay;
+ cout << "How many hours did you work this week?: ";
+ cin >> Hours;
+ if (Hours < 0) {
+ cout << "Invalid option!" << endl;
+ return 2;
+ }
+ cout << "How many dependents do you have?: ";
+ cin >> Dependents;
+ if (Hours > 40) { //Every hour over 40 constitutes as overtime
+ OT=Hours-40;
+ }
+ if (Dependents >= 3 && Hours > 0) { //More than 3 dependents carries a fee
+ Health=35;
+ }
+ GrossPay = Hours * 16.78 + OT * 16.78 * 1.5;
+ SocSec = GrossPay * 0.06;
+ Fed = GrossPay * 0.14;
+ State = GrossPay * .05;
+ if (GrossPay>0){
+ Union=10;
+ }
+ NetPay = GrossPay - SocSec - Fed - State - Health - Union;
+ cout << fixed << setprecision(2) << endl << "Your gross (before withholdings) pay is $" << GrossPay << "." << endl
+ << "Social Security withholding: $" << SocSec << endl
+ << "Federal income tax withholding: $" << Fed << endl
+ << "State income tax withholding: $" << State << endl
+ << "Union Dues: $" << Union << endl
+ << "Medical cost: $" << Health << endl
+
+ << "Your net (after witholdings) pay is $" << NetPay << "." << endl;
+
+}