aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-26 14:47:50 -0700
committerWiserJ <[email protected]>2021-10-26 14:47:50 -0700
commitad612098a0ba109c432029ca808ada9e6bce4076 (patch)
treeafc6bd39b748bf396976cde825857a2637191039
parentinputs (diff)
downloadcst116-lab4-jeffwoit-ad612098a0ba109c432029ca808ada9e6bce4076.tar.xz
cst116-lab4-jeffwoit-ad612098a0ba109c432029ca808ada9e6bce4076.zip
2:47
-rw-r--r--CST116F2021-Lab4/CST116F2021-Lab4.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/CST116F2021-Lab4/CST116F2021-Lab4.cpp b/CST116F2021-Lab4/CST116F2021-Lab4.cpp
index 1006a43..3cd63cc 100644
--- a/CST116F2021-Lab4/CST116F2021-Lab4.cpp
+++ b/CST116F2021-Lab4/CST116F2021-Lab4.cpp
@@ -6,15 +6,18 @@
using namespace std;
-void GetInput(int, int, int);
-void DisplayTime(float, float, float);
+void GetInput(int& hours, int& minutes, int& seconds);
+void DisplayTime(int& hours_display, int& minutes_display, int& seconds_display);
int main()
{
+ int hours = 0, minutes = 0, seconds = 0;
+ GetInput(hours, minutes, seconds);
+ DisplayTime(hours, minutes, seconds);
}
-void GetInput(int hours_input, int minutes_input, int seconds_input)
+void GetInput(int& hours_input, int& minutes_input, int& seconds_input)
{
do
{
@@ -26,17 +29,33 @@ void GetInput(int hours_input, int minutes_input, int seconds_input)
{
cout << "Please enter the current minutes out of 60 per hour: ";
cin >> minutes_input;
- } while (minutes_input <= 0 || minutes_input > 60);
+ } while (minutes_input < 0 || minutes_input > 60);
do
{
cout << "Please enter the current seconds out of 60 per minute: ";
cin >> seconds_input;
- } while (seconds_input <= 0 || seconds_input > 60);
+ } while (seconds_input < 0 || seconds_input > 60);
}
-void DisplayTime(float standard_display, float military_display, float hours_display)
+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 -= 12;
+ suffix = " P.M.";
+ }
+ else
+ {
+ suffix = " A.M.";
+ }
+
+
+ cout << "The current time in standard time is " << hours_display << ":" << setw(2) << setfill('0') << minutes_display << ":" << setw(2) << setfill('0') << seconds_display << suffix;
+
}