#ITP 120 student

1 messages · Page 1 of 1 (latest)

fallen acornBOT
#

<@&987246399047479336> please have a look, thanks.

#

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?

ornate ledge
#

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

restive maple
#

you started yet?

ornate ledge
#

kinda

restive maple
#

ok what are you struggling with exactly?

ornate ledge
#

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

restive maple
#

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

ornate ledge
#

this is what I have written.

restive maple
#

fields are on class level

#

so like:

public class Test {
    public static final int THIS_IS_A_FIELD_VARIABLE = 0;
}
restive maple
ornate ledge
#

my main method will hold the formula to calculate the math right?

#

so creat a new class named that variable? so on so forth?

restive maple
#

depends, you would typically create a dedicated method for that

restive maple
#

you should just create variables on class level

true lynx
#

I think you need to take a gander at your chapter 1 and 2 material again

ornate ledge
true lynx
#

variable declaration for one

#

when unsure it's best to break it down

ornate ledge
#

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)

true lynx
#

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

true lynx
ornate ledge
#

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?

true lynx
#

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

fallen acornBOT
#

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.

ornate ledge
#

@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;
}
restive maple
#

you are missing one closing bracket at the end

#

for the class

ornate ledge
#

damn bro i get more errors putting in the bracket

restive maple
#

share them

ornate ledge
restive maple
#

you should close it

#

at the end

#

both methods needs to be inside the class

#

inside means inside its brackets

ornate ledge
#

okay im so sorry man. did i fix it? im still not getting it to run

restive maple
#

you now completely removed the bracket

#

put it at the end

ornate ledge
#

i put it back my bad mate

restive maple
#

bruh

restive maple
ornate ledge
#

on linw 30?

restive maple
#

yea

#

thats the end

ornate ledge
#

bro im sorry for not understanding but theres a bracket on line 29 already

restive maple
#

thats the one for closing the method

#

so put another

ornate ledge
#

i put one on line 30 too bro and still im getting the same error

restive maple
#

show it

ornate ledge
restive maple
#

remove the one on line 5

ornate ledge
#

removed it and it gave an error again one sec ill sc

restive maple
#

?

#

you didnt remove line 5

ornate ledge
#

dude omg wrong sc my bad

restive maple
#

ah ok

ornate ledge
restive maple
#

open the run configuration

#

top right

#

next to the run button

#

and then press edit

#

screenshot that

ornate ledge
#

damn bro u there? @restive maple