Question
Need someone to edit the code based on the following In your code, you must use: at least two integral types (int, long, etc.) at
Need someone to edit the code based on the following
In your code, you must use: at least two integral types (int, long, etc.) at least one real number (double or float) at least one character array (char and char* as used for text like cat hungry). Prompt the user for each variable, read the variable from the console, and print the resulting decision.
#include
int main()
{
double wakeup = 0;
int days_since_gym = 0;
int sleep_well_last_night = 0;
int sunday = 0;
printf("when did you wake up ? (write in 24 hrs format and convert to float. 7:45 pm should be written as 19.75) ");
scanf("%lf", &wakeup);
while (wakeup < 0 || wakeup >= 24)
{
printf("Please enter a valid time. It should be in [0,24) ");
scanf("%lf", &wakeup);
}
printf("How many days have passed since you last went gym? ");
scanf("%d", &days_since_gym);
while (days_since_gym < 0)
{
printf("Please enter a valid no. It can'y be negative ");
scanf("%d", &days_since_gym);
}
printf("Did you sleep well last night? Press 1 for yes 0 for no ");
scanf("%d", &sleep_well_last_night);
while (sleep_well_last_night != 1 && sleep_well_last_night != 0)
{
printf("Please enter a valid no. It can either be 1 or 0 ");
scanf("%d", &sleep_well_last_night);
}
printf("Is today a sunday? Press 1 for yes 0 for no ");
scanf("%d", &sunday);
while (sunday != 1 && sunday != 0)
{
printf("Please enter a valid no. It can either be 1 or 0 ");
scanf("%d", &sunday);
}
if((wakeup==7.00 && days_since_gym>=3) || (sleep_well_last_night==0 && sunday==1)){
printf("You should do some exeercises. It is recommended to walk 5000 steps a day. ");
}else{
printf("No need of doing exercises today:) Although it is recommended to walk 5000 steps a day. ");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started