#ITP 120 student
1 messages · Page 1 of 1 (latest)
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
a certain amount of time. Can you provide more details about the activities and the time duration for each activity?
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 formula:
Calories/Minute = 0.0175 × MET × Weight(Kg)
Write a program that calculates and outputs the tot al 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.
You must create a class level/scope variable for every "constant" value that you have, such as the number of METS per each activity - there are several others as well that will not change no matter how many different scenarios this program is run for, so make sure they are all defined this way and other values that could vary if you ran it for different people/scenarios can be declared as method level/scope variables (in your main() method in this case).
Chapter 8 will cover the concept of "static", but for now, declare all of your class level/scope variables as "public static final".
This is the instructions for said assignment
you started yet?
kinda
ok what are you struggling with exactly?
I'm struggling with the instructions first off. I have no idea what they mean by creating a class variable for each constant value?
im trying to figure out how to screenshot to show you what i have written already
they probably mean static field variable
Chapter 8 will cover the concept of "static", but for now, declare all of your class level/scope variables as "public static final".
so you are supposed to declare all constants as public static final
this is what I have written.
fields are on class level
so like:
public class Test {
public static final int THIS_IS_A_FIELD_VARIABLE = 0;
}
all those are inside a (main) method
my main method will hold the formula to calculate the math right?
so creat a new class named that variable? so on so forth?
depends, you would typically create a dedicated method for that
new class?
you should just create variables on class level
I think you need to take a gander at your chapter 1 and 2 material again
which aspect exactly?
got it let me look man. Im sorry if this question is stupid its actually my first class like this so I've been SCRAMBLING trying to figure everything out on my own (its an online class)
so what do you see in the task:
declare constants
have a method that for a given weight, for a given period, for a given met calculates the burned calories
sum it up
oh I get that, that's what I mean. It's a lot easier if you break it down in smaller chunks.
yeah bro thank you i went back and I think i get what you guys were saying.
it would look like that? and then i would place values the same way as the other screen shot?
@restive maple sorry man like that?
No, like Squid mentioned.
So you have something like
public class Chpt2Part1 {
private static final int RUNNING = 10;
private static final int BASKETBALL = 8;
private static final int SLEEPING = 1;
private static final Double WHAT_THIS_REPRESENTS = 0.0175;
...
}
Also please use
Please use this format for posting code:
```java
// Example java program
int value = 5;
System.out.println(value);
```
Which results in:
// Example java program
int value = 5;
System.out.println(value);
For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.
* double
@restive maple can you explain this error bro?
public class CalorieCalculator {
public static final double RUNNING_MET = 10.0;
public static final double BASKETBALL_MET = 8.0;
public static final double SLEEPING_MET = 1.0;
public static void main(String[] args) {
// Assuming weight is in pounds
double weightPounds = 150.0;
double weightKg = weightPounds / 2.2;
// Running 6 MPH for 30 minutes
double runningCalories = calculateCalories(RUNNING_MET, weightKg, 30);
// Playing basketball for 30 minutes
double basketballCalories = calculateCalories(BASKETBALL_MET, weightKg, 30);
// Sleeping for 6 hours (360 minutes)
double sleepingCalories = calculateCalories(SLEEPING_MET, weightKg, 360);
// Total calories burned
double totalCalories = runningCalories + basketballCalories + sleepingCalories;
System.out.println("Total calories burned: " + totalCalories);
}
public static double calculateCalories(double met, double weightKg, int minutes) {
// Calories/Minute — 0.0175 x MET x Weight(Kg)
return 0.0175 * met * weightKg * minutes;
}
damn bro i get more errors putting in the bracket
share them
you should close it
at the end
both methods needs to be inside the class
inside means inside its brackets
okay im so sorry man. did i fix it? im still not getting it to run
i put it back my bad mate
bruh
^^^
on linw 30?
bro im sorry for not understanding but theres a bracket on line 29 already
i put one on line 30 too bro and still im getting the same error
show it
remove the one on line 5
dude omg wrong sc my bad
ah ok