Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Show me the steps to solve For every 3 , 0 0 0 calories of food that we eat which does not get burned within
Show me the steps to solve For every calories of food that we eat which does not get burned within a week,
we gain pound. This means we must keep track not only of the calories we consume,
but of the energy we spend burning them.
Description of Program
Write a program that will ask the user questions each day for days:
How many calories they consume.
How many calories did they burn.
Store each days answers in pairs of int global variables,
dayCalConsumed, dayCalBurned, dayCalConsumed, dayCalBurned,
dayCalConsumed, dayCalBurned, dayCalConsumed, dayCalBurned,
dayCalConsumed, dayCalBurned, dayCalConsumed, dayCalBurned,
dayCalConsumed, dayCalBurned
After getting all pairs of values from the user, calculate the int global variables
called totalCaloriesConsumed and the totalCaloriesBurned for those days.
Then, calculate the double global variables called averageCaloriesConsumed and
averageCaloriesBurned.
Finally, calculate the double global variable netWeeklyPounds which is how many
pounds you have gainedlost this week, by subtracting totalCaloriesBurned from
totalCaloriesConsumed, and then dividing by
double netWeeklyPounds doubletotalCaloriesConsumed totalCaloriesBurned
;
Display the value of all the variables to the user.
Structure of Program
Create methods:
getUserInput to get & store the pairs of values
calculateCalories to calculate totals and averages
displayCalories to display all of the information to the user
Example of Display to User: Note: yellow designates examples of user replies
Enter calories consumed for day #:
Enter calories burned for day #:
Enter calories consumed for day #:
Enter calories burned for day #:
Enter calories consumed for day #:
Enter calories burned for day #:
Enter calories consumed for day #:
Enter calories burned for day #:
Enter calories consumed for day #:
Enter calories burned for day #:
Enter calories consumed for day #:
Enter calories burned for day #:
Enter calories consumed for day #:
Enter calories burned for day #:
You consumed a total of calories this week.
You burned a total of calories this week.
You consumed an average of calories a day.
You burned an average of calories a day.
Your net weekly gainloss were pounds.
Hint: You may need to use System.out.printf to get the correct formatting of the numbers.
System.
out.printTotal Calories Consumed are: ;
System.
out.printff
totalAmount;
System.
out.printTotal Calories Burned are: ;
System.
out.printff
totalBurned
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