aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-26 15:37:10 -0700
committerWiserJ <[email protected]>2021-10-26 15:37:10 -0700
commit496c4fb20b473637d5127d5e66d825b88c4981f9 (patch)
treef4c8920e2fb8b39f72b46a08560deab20f2fec22
parenthours display (diff)
downloadcst116-lab4-jeffwoit-496c4fb20b473637d5127d5e66d825b88c4981f9.tar.xz
cst116-lab4-jeffwoit-496c4fb20b473637d5127d5e66d825b88c4981f9.zip
maybe finished
-rw-r--r--CST116F2021-Lab4/CST116F2021-Lab4.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/CST116F2021-Lab4/CST116F2021-Lab4.cpp b/CST116F2021-Lab4/CST116F2021-Lab4.cpp
index 8973760..451500b 100644
--- a/CST116F2021-Lab4/CST116F2021-Lab4.cpp
+++ b/CST116F2021-Lab4/CST116F2021-Lab4.cpp
@@ -43,31 +43,33 @@ void DisplayTime(int& hours_display, int& minutes_display, int& seconds_display)
//set hours to 12 hours time before cout
string suffix;
- if (hours_display > 12 && hours_display != 0)
+ if (hours_display > 12 && hours_display != 0) //fix for PM time
{
hours_display -= 12;
suffix = " P.M.";
}
- else if (hours_display == 12)
+ else if (hours_display == 12) //fix for 12 noon
suffix = " P.M.";
- else if (hours_display == 0)
+ else if (hours_display == 0) //fix for 12 midnight
{
hours_display += 12;
suffix = " A.M.";
}
- else
+ else //remaining times are AM
suffix = " A.M.";
cout << "\nThe current time in standard time is " << hours_display << ":" << setw(2) << setfill('0') << minutes_display << ":" << setw(2) << setfill('0') << seconds_display << suffix;
- if (suffix == " A.M." && hours_display == 12)
+ //Revert back to 24 hour format
+
+ if (suffix == " A.M." && hours_display == 12) //fix for midnight
hours_display = 0;
- else if (suffix == " P.M.")
+ else if (suffix == " P.M.") //fix for PM times
hours_display += 12;
cout << "\nThe current time in military time is " << setw(2) << setfill('0') << hours_display << setw(2) << setfill('0') << minutes_display << ":" << setw(2) << setfill('0') << seconds_display;
- cout << "\nThe current time in military time is " << setw(2) << setfill('0') << hours_display << ":" << setw(2) << setfill('0') << minutes_display << ":" << setw(2) << setfill('0') << seconds_display;
+ cout << "\nThe current time in 24 hour notation time is " << setw(2) << setfill('0') << hours_display << ":" << setw(2) << setfill('0') << minutes_display << ":" << setw(2) << setfill('0') << seconds_display;
}
//p.214