Question
PLEASE HELP ME FIX THE CODE IN JAVA: One way to measure the amount of energy that is expended during exercise is to use metabolic
PLEASE HELP ME FIX THE CODE IN JAVA:
One way to measure the amount of energy that is expended during exercise is to use metabolic equivalents (MET). Here are some METS for various activities: Running 6 MPH: 10 METS Basketball: 8 METS Sleeping: 1 MET The number of calories burned per minute may be estimated using the following formula: CaloriesjMinute = 0.0175 * MET * Weight in kilograms Write a program that calculates and outputs the total number of calories burned for a 150-pound person who runs 6 MPH for 30 minutes, plays basketball for 30 minutes, and then sleeps for 6 hours. One kilogram is equal to 2.2 pounds.
MY CODE:
//CaloriesCalculator.java public class CaloriesCalculator { public static final double KILOGRAMS_PER_POUND = 2.2; public static final int RUNNING_METS = 10; public static final int BASKETBALL_METS = 8; public static final int SLEEPING_METS = 1; public static void main(String[] args) { double weightInKilograms = 150 / KILOGRAMS_PER_POUND; double runningTimeInMinutes = 30; double basketballTimeInMinutes = 30; double sleepintTimeInMinutes = 6 * 60; double caloriesBurnedForRunning = 0.0175 * RUNNING_METS * weightInKilograms * runningTimeInMinutes; double caloriesBurnedForBasketball = 0.0175 * BASKETBALL_METS * weightInKilograms * basketballTimeInMinutes; double caloriesBurnedForSleeping = 0.0175 * SLEEPING_METS * weightInKilograms * sleepintTimeInMinutes; double totalCaloriesBurned = caloriesBurnedForRunning + caloriesBurnedForBasketball + caloriesBurnedForSleeping; System.out.println( "Number of calories burned for running: " + caloriesBurnedForRunning);
System.out.println( "Number of calories burned for basketball: " + caloriesBurnedForBasketball); System.out.println( "Number of calories burned for sleeping: " + caloriesBurnedForSleeping);
System.out.println( " Total number of calories burned per minute: " + totalCaloriesBurned); } }
**RESULT**
COMPILER ERROR MESSAGES
CalorieBurnedCalculator.java:2: error: class CaloriesCalculator is public, should be declared in a file named CaloriesCalculator.java public class CaloriesCalculator ^ 1 error
1 //CaloriesCalculator.java 2 public class CaloriesCalculator 3 { 4 public static final double KILOGRAMS_PER_POUND = 2.2; 5 public static final int RUNNING_METS = 10; 6 public static final int BASKETBALL_METS = 8; 7 public static final int SLEEPING_METS = 1; 8 9 public static void main(String[] args) 10 { 11 double weightInKilograms = 150 / KILOGRAMS_PER_POUND; 12 double runningTimeInMinutes = 30; 13 double basketballTimeInMinutes = 30; 14 double sleepintTimeInMinutes = 6 * 60; 15 16 double caloriesBurnedForRunning = 0.0175 17 * RUNNING_METS * weightInKilograms 18 * runningTimeInMinutes; 19 20 double caloriesBurnedForBasketball = 0.0175 21 * BASKETBALL_METS * weightInKilograms 22 * basketballTimeInMinutes; 23 24 double caloriesBurnedForSleeping = 0.0175 25 * SLEEPING_METS * weightInKilograms 26 * sleepintTimeInMinutes; 27 28 double totalCaloriesBurned = caloriesBurnedForRunning 29 + caloriesBurnedForBasketball 30 + caloriesBurnedForSleeping; 31 32 System.out.println( 33 "Number of calories burned for running: " 34 + caloriesBurnedForRunning); 35 36 System.out.println( 37 "Number of calories burned for basketball: " 38 + caloriesBurnedForBasketball); 39 40 System.out.println( 41 "Number of calories burned for sleeping: " 42 + caloriesBurnedForSleeping); 43 44 System.out.println( 45 " Total number of calories burned per minute: " 46 + totalCaloriesBurned); 47 } 48 }
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