aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk2
diff options
context:
space:
mode:
Diffstat (limited to 'ee1301/wk2')
-rw-r--r--ee1301/wk2/hw2_directory/strap012_HW2A.cpp (renamed from ee1301/wk2/hw2_directory/strap012_2A.cpp)0
-rw-r--r--ee1301/wk2/hw2_directory/strap012_HW2B.cpp (renamed from ee1301/wk2/hw2_directory/strap012_2B.cpp)43
-rw-r--r--ee1301/wk2/hw2_directory/strap012_HW2C.cpp (renamed from ee1301/wk2/hw2_directory/strap012_2C.cpp)0
3 files changed, 23 insertions, 20 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_2A.cpp b/ee1301/wk2/hw2_directory/strap012_HW2A.cpp
index 3129241..3129241 100644
--- a/ee1301/wk2/hw2_directory/strap012_2A.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_HW2A.cpp
diff --git a/ee1301/wk2/hw2_directory/strap012_2B.cpp b/ee1301/wk2/hw2_directory/strap012_HW2B.cpp
index fb07e18..dd130ba 100644
--- a/ee1301/wk2/hw2_directory/strap012_2B.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_HW2B.cpp
@@ -9,45 +9,49 @@ Short Program Description: Time Travel Calculator
*/
//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.
+//I've been trying this for more than six hours and it has still made no sense
+//Nested if and for statements are a nightmare
#include <iostream>
using namespace std;
int main()
{
- bool change12 = 0, foo = 0, bar = true; //Workaround to prevent unneeded if statements
- char Time, travel; //"time" is reserved by C++, "Time" is not
+ 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 >> travel >> hourChange;
+ cin >> hourChange >> travel;
for (int i = hourChange; i >= 0; i--)
{
if (i != 0)
{
intervalChange++;
}
-
- if (travel == 'F')
+ /* do
{
- if (hourOG + hourChange >= 12 && bar)
+ STILL BROKEN
+ if (travel == 'B' && hourOG - intervalChange < 0)
{
- if (hourOG + hourChange == 12)
+ if (hourChange < 12)
{
- timeChange++;
+ intervalChange = 12 - hourChange;
}
else
{
- hourNew = (hourOG + hourChange) - 12;
- bar = false;
+ intervalChange = hourChange - 12;
+ if (intervalChange >= 13)
+ {
+ intervalChange -= 12;
+ }
}
+ timeChange++;
}
- }
+ STILL BROKEN
- if (travel == 'B')
- {
- }
+ } while (intervalChange > 12); */
if (intervalChange >= 12)
{
intervalChange = 0;
@@ -60,15 +64,15 @@ int main()
if (Time == 'A')
{
Time += 15;
+ foo = true;
}
- else
+ if (Time == 'P' && !foo)
{
- if (Time == 'P')
- {
- Time -= 15;
- }
+ Time -= 15;
}
+ foo = 0;
}
+
if (travel == 'F')
{
hourNew = hourOG + intervalChange;
@@ -77,7 +81,6 @@ int main()
{
hourNew = hourOG + intervalChange;
}
-
cout << "The new time is: " << hourNew << " " << Time << "M" << endl;
return 0;
} \ No newline at end of file
diff --git a/ee1301/wk2/hw2_directory/strap012_2C.cpp b/ee1301/wk2/hw2_directory/strap012_HW2C.cpp
index f300a04..f300a04 100644
--- a/ee1301/wk2/hw2_directory/strap012_2C.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_HW2C.cpp