diff options
author | RossTheRoss <msattr@gmail.com> | 2019-02-19 21:13:02 +0000 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-02-19 21:13:02 +0000 |
commit | 5244ec7aa2074cbbf450ba91e1fffa108ac11101 (patch) | |
tree | 0d3ca6a944f5e54ec92161347464fd0aab69e118 | |
parent | Start 2B (NOT FINISHED) (diff) | |
download | homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.tar homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.tar.gz homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.tar.bz2 homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.tar.lz homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.tar.xz homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.tar.zst homework-5244ec7aa2074cbbf450ba91e1fffa108ac11101.zip |
(Screams internally)
Diffstat (limited to '')
-rw-r--r-- | ee1301/wk2/hw2_directory/strap012_2B.cpp | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_2B.cpp b/ee1301/wk2/hw2_directory/strap012_2B.cpp index e72b96d..b07028a 100644 --- a/ee1301/wk2/hw2_directory/strap012_2B.cpp +++ b/ee1301/wk2/hw2_directory/strap012_2B.cpp @@ -4,23 +4,42 @@ Name: Matthew Strapp Student ID number: 5449340 Course number: EE1301 Term: Spring 2019 -Lab/assignment number: Homework 2C -Short Program Description: Pay Stub Calculator +Lab/assignment number: Homework 2B +Short Program Description: Time Travel Calculator */ //15 #include <iostream> using namespace std; int main () { - bool change12=0; //Workaround to prevent unneeded if statements - char Time, travel; //"time" is reserved - int hourOG, hourChange, hourNew, timeChange=0; + + bool change12=0, foo=0; //Workaround to prevent unneeded if statements + char Time, travel; //"time" is reserved by C++, "Time" is not + int hourOG, hourChange, hourNew, intervalChange=0, timeChange=1; 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 >> hourChange >> travel; - - if (hourOG+hourChange>=12 || hourOG-hourChange<=0) { + for (int i=hourChange; i>=0; i--) { + if (i!=0){ + intervalChange++; + } do { + if (travel=='B' && hourOG-intervalChange<0){ + if (hourChange<12) + intervalChange=12-hourChange; + else + intervalChange=hourChange-12; + } + } while (intervalChange>12); + if (intervalChange>=12) { + //if (intervalChange !=12) {i + intervalChange=0; + timeChange++; + //change12=1; + } + } + +/* if (hourOG+hourChange>=12 || hourOG-hourChange<=0) { if (hourOG!=0 ^ hourOG!=12) { hourOG-=12; } @@ -32,23 +51,29 @@ int main () { } change12=1; } - for (timeChange; timeChange>0; timeChange--) { - if (change12) { +*/ + + for (timeChange; timeChange>1; timeChange--) { + //if (change12) { if (Time=='A') { Time+=15; + foo=true; } - if (Time=='P') { + if (Time=='P' && !foo) { Time-=15; } - } + foo=0; + //} } + if (travel=='F') { - hourNew=hourOG+hourChange; + hourNew=hourOG+intervalChange; } if (travel=='B'){ - hourNew=hourOG-hourChange; + hourNew=hourOG+intervalChange; } - + //Deprecated, doesn't work + //hourNew=hourOG+intervalChange; cout << "The new time is: " << hourNew << " " << Time << "M" << endl; return 0; |