"Write a program that computes the amount of calories burned when you run. Your program should ask for the duration of the run in minutes the speed of the run in mph and the weight in pounds. Computes the amount of calories burned and prints it. The calories/minute of run burned is computed using the expression below:\n", "\n", "$$????????/??????=(???∗????ℎ?∗1.6)/200$$\n", " \n", "Use a function to compute the value of MET as presented in the table below.\n", "\n", "| Speed (mph) | MET |\n", "|--------------|---------|\n", "| 5 or less | 8.3 |\n", "| 6 | 9.8 |\n", "| 7 | 11.0 |\n", "| 8 | 11.8 |\n", "| 9 | 12.8 |\n", "| 10 | 14.5 |\n", "| 12 or more | 19.0 |\n", "\n", "For values in between use the largest MET. Test your code with the values:\n", "```\n", "150 lbs, 6.5 mph and 45 minutes ==> 594.0 calories\n", "200 lbs, 9.8 mph and 30 minutes ==> 696.0 calories\n",
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
"Write a program that computes the amount of calories burned when you run. Your program should ask for the duration of the run in minutes the speed of the run in mph and the weight in pounds. Computes the amount of calories burned and prints it. The calories/minute of run burned is computed using the expression below:\n",
"\n", "$$????????/??????=(???∗????ℎ?∗1.6)/200$$\n",
" \n", "Use a function to compute the value of MET as presented in the table below.\n",
"\n",
"| Speed (mph) | MET |\n", "|--------------|---------|\n", "| 5 or less | 8.3 |\n", "| 6 | 9.8 |\n", "| 7 | 11.0 |\n", "| 8 | 11.8 |\n", "| 9 | 12.8 |\n", "| 10 | 14.5 |\n", "| 12 or more | 19.0 |\n", "\n",
"For values in between use the largest MET. Test your code with the values:\n", "```\n", "150 lbs, 6.5 mph and 45 minutes ==> 594.0 calories\n", "200 lbs, 9.8 mph and 30 minutes ==> 696.0 calories\n",
Step by step
Solved in 4 steps with 2 images