C++ Question! When answering this question, please do so in the format of a begi
ID: 3824532 • Letter: C
Question
C++ Question!
When answering this question, please do so in the format of a begininer so it can be easier to understand.
Explain it well, thank you!
2) [15 points You've been hired by Clock Towers Unlimited to write software to list each hour of a 24-hour day. Write a Visual C++ program to list the hours of the day using a for statement, Start at midnight (hour 0 and end at 11pm Chour 230. For each hour, also list which part of the day it is. Use an if statement, the hour of the day, and the following table to determine which part of the day it is. Hour range Part of day 0-5 Early morning 6-11 Morning 12-17 Afternoon 18-23 EveningExplanation / Answer
#include<iostream>
#include <windows.h>
using namespace std;
int main()
{
int minutes = 0; // set the minutes
int hours = 0; //set the hour
Loop:
for (int sec = 0; sec < 61; sec++)
{
if (sec == 60)
{
minutes = minutes + 1;
sec = sec - 60;
goto Loop;
}
if (minutes == 60)
{
hours = hours + 1;
minutes = 0;
goto Loop;
}
if (hours >=0 && hours <=5)
{
system("cls");
cout <<"Early Morning "<<"Hours:"<<hours<<"/ Minutes:"<<minutes<<"/ Seconds:"<<sec;
Sleep(1000);
}
if (hours >=6 && hours <=11)
{
system("cls");
cout <<"Morning "<<"Hours:"<<hours<<"/ Minutes:"<<minutes<<"/ Seconds:"<<sec;
Sleep(1000);
}
if (hours >=12 && hours <=17)
{
system("cls");
cout <<"Afternoon "<<"Hours:"<<hours<<"/ Minutes:"<<minutes<<"/ Seconds:"<<sec;
Sleep(1000);
}
if (hours >=18 && hours <=23)
{
system("cls");
cout <<"Evening "<<"Hours:"<<hours<<"/ Minutes:"<<minutes<<"/ Seconds:"<<sec;
Sleep(1000);
if (hours==23)
break;
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.