Answer to Question #110900 in C++ for bob joe

Question #110900
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 (hour 23). 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.
1
Expert's answer
2020-04-20T15:12:03-0400
// the preprocessing directives

#include <iostream>              // cin, cout

#include <iomanip>               // setw(n)

using namespace std;

int main()

{
     int i;

     cout<<"Hour  Part of day"<<endl;

     cout<<"================="<<endl;

for(i=0;i<=23;i++)

   {

        cout<<setw(2)<<i<<":  ";

        if(i>=0 && i<=5)                             // Hour range:  0 - 5

              cout<< "Early moning"<<endl;           // Part of day: Early moning

         else if(i>=6 && i<=11)                       // Hour range:  6 - 11

              cout<< "Moning"<<endl;                   // Part of day: Moning

          else if(i>=12 && i<=17)                      // Hour range:  12 - 17

              cout<< "Afternoon"<<endl;                // Part of day: Afternoon

          else                                          // Hour range:  18 - 23

               cout<< "Evening"<<endl;                   // Part of day: Evening

}

   cout<<endl<<endl;

   return 0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS