diff options
author | RossTheRoss <msattr@gmail.com> | 2019-02-19 21:33:40 -0600 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-02-19 21:33:40 -0600 |
commit | d380237685e859af1463aa92999c976468cd4b19 (patch) | |
tree | b739a741cc82249c314770d1cbf3829970892daa /ee1301/wk2 | |
parent | Remember last curly brace in main() (diff) | |
download | homework-d380237685e859af1463aa92999c976468cd4b19.tar homework-d380237685e859af1463aa92999c976468cd4b19.tar.gz homework-d380237685e859af1463aa92999c976468cd4b19.tar.bz2 homework-d380237685e859af1463aa92999c976468cd4b19.tar.lz homework-d380237685e859af1463aa92999c976468cd4b19.tar.xz homework-d380237685e859af1463aa92999c976468cd4b19.tar.zst homework-d380237685e859af1463aa92999c976468cd4b19.zip |
AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Diffstat (limited to 'ee1301/wk2')
-rw-r--r-- | ee1301/wk2/hw2_directory/strap012_2B.cpp | 67 |
1 files changed, 63 insertions, 4 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_2B.cpp b/ee1301/wk2/hw2_directory/strap012_2B.cpp index 5adefd5..fb07e18 100644 --- a/ee1301/wk2/hw2_directory/strap012_2B.cpp +++ b/ee1301/wk2/hw2_directory/strap012_2B.cpp @@ -7,18 +7,77 @@ Term: Spring 2019 Lab/assignment number: Homework 2B Short Program Description: Time Travel Calculator */ -//15 + +//PROGRAMMER'S NOTE: This problem legitimately stumped me. I won't be suprised if this is where I lose most of my points for this assignment. #include <iostream> using namespace std; int main() { - bool change12=0, foo=0, bar=false; //Workaround to prevent unneeded if statements - char Time, travel; //"time" is reserved by C++, "Time" is not + bool change12 = 0, foo = 0, bar = true; //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; + cin >> travel >> hourChange; + for (int i = hourChange; i >= 0; i--) + { + if (i != 0) + { + intervalChange++; + } + + if (travel == 'F') + { + if (hourOG + hourChange >= 12 && bar) + { + if (hourOG + hourChange == 12) + { + timeChange++; + } + else + { + hourNew = (hourOG + hourChange) - 12; + bar = false; + } + } + } + + if (travel == 'B') + { + } + if (intervalChange >= 12) + { + intervalChange = 0; + timeChange++; + } + } + + for (timeChange; timeChange > 1; timeChange--) + { + if (Time == 'A') + { + Time += 15; + } + else + { + if (Time == 'P') + { + Time -= 15; + } + } + } + if (travel == 'F') + { + hourNew = hourOG + intervalChange; + } + if (travel == 'B') + { + hourNew = hourOG + intervalChange; + } + + cout << "The new time is: " << hourNew << " " << Time << "M" << endl; + return 0; }
\ No newline at end of file |