Question: Goal: Use the switch case statement and perform input validation. Assignment: Develop a program for a fitness activity tracker that displays a menu for different

Goal: Use the switch case statement and perform input validation.
Assignment: Develop a program for a fitness activity tracker that displays a menu for different types of physical activities. The program will calculate and display the estimated calories burned for that activity based on the user's choice.
Menu Structure:
Jogging
Cycling
Swimming
Quit
Enter your choice (1-4): User Choices and Prompts:
If the user enters 1(Jogging):
Prompt: "
Enter the time spent jogging in minutes: "
Read the duration as input.
Calculate calories burned using the formula: Calories =0.75* duration
Print: "
Calories burned: ", followed by the calculated value, followed by a newline.
If the user enters 2(Cycling):
Prompt: "
Enter the time spent cycling in minutes: "
Read the duration.
Calculate calories burned using: Calories =0.5* duration
Print the result as above.
If the user enters 3(Swimming):
Prompt: "
Enter the time spent swimming in minutes: "
Read the duration.
Calculate calories burned using: Calories =0.8* duration
Print the result as above.
If the user enters 4(Quit):
Print: "
Program ending.
" Valid menu choices are 1,2,3, or 4. If invalid, print: "
Valid choices are 1 through 4. Try again.
"
Sample Run
Fitness Activity Tracker
1. Jogging
2. Cycling
3. Swimming
4. Quit
Enter your choice (1-4): [2]
Enter the duration in minutes: [30]
Calories burned: [15.0]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!