Program will determine the hours you need to work based on certain criteria. Pro
ID: 3763590 • Letter: P
Question
Program will determine the hours you need to work based on certain criteria.
Program should get input for day of week as an integer: Monday = 1; Tuesday = 2; etc through Sunday = 7.
Program should get input for “Are You Sick” as a Boolean.
Use an if statement to determine the day of the week and if you are sick or not.
If the day is Monday through Friday and you are NOT sick then perform the following:
Using a switch statement, output:
Monday output "I hate Mondays, Work Hours for today are 8-5"
Wednesday output “Work Hours for today are 8-5”
Tuesday output “Work Hours for today are 7-4”
Friday output “SWEET it is Friday, Noon can't get here fast enough, Work Hours for today are 8-12”
All other days, output “Take the day off”. (this should only be called on Thursday)
All other days (Saturday and Sunday) output “Stay in bed! Unless you have a to do list”
Above should be in a do while loop that should continue until I enter “y” at the prompt: “Would you like to run again? (y/n)
Explanation / Answer
As you didn't specified the language in which you want the code, I'm implementing this using C++. If you need any further modification, just get back to me. Here is the code for you.
#include <iostream>
using namespace std;
int main()
{
int day;
bool sickStatus;
char again;
do
{
cout<<"Enter the day of the week(1: Monday - 7:Sunday.): ";
cin>>day;
cout<<"Are you Sick: ";
cin>>sickStatus;
if(day >= 1 && day < 6 && sickStatus == false) //Day is Monday through Friday and not SICK.
{
switch(day)
{
case 1:
cout<<"I hate Mondays, Work Hours for today are 8-5"<<endl;
break;
case 2:
cout<<"Work Hours for today are 7-4"<<endl;
break;
case 3:
cout<<"Work Hours for today are 8-5"<<endl;
break;
case 4:
cout<<"Take the day off"<<endl;
break;
case 5:
cout<<"SWEET it is Friday, Noon can't get here fast enough, Work Hours for today are 8-12"<<endl;
break;
}
}
else
cout<<"Stay in bed! Unless you have a to do list"<<endl;
cout<<"Would you like to run again? (y/n): ";
cin>>again;
}while(again == 'y');
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.