Answered step by step
Verified Expert Solution
Link Copied!

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 3,000 calories of food that we eat which does not get burned within a week,
we gain 1 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 2 questions each day for 7 days:
1.) How many calories they consume.
2.) How many calories did they burn.
Store each days answers in 7 pairs of int global variables,
day1CalConsumed, day1CalBurned, day2CalConsumed, day2CalBurned,
day3CalConsumed, day3CalBurned, day4CalConsumed, day4CalBurned,
day5CalConsumed, day5CalBurned, day6CalConsumed, day6CalBurned,
day7CalConsumed, day7CalBurned
After getting all 7 pairs of values from the user, calculate the int global variables
called totalCaloriesConsumed and the totalCaloriesBurned for those 7 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 gained/lost this week, by subtracting totalCaloriesBurned from
totalCaloriesConsumed, and then dividing by 3,000.
double netWeeklyPounds =(double)(totalCaloriesConsumed totalCaloriesBurned)
/3000.0;
Display the value of all the variables to the user.
Structure of Program
Create 3 methods:
getUserInput() to get & store the 7 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 #1: 1000
Enter calories burned for day #1: 1200
Enter calories consumed for day #2: 2000
Enter calories burned for day #2: 2000
Enter calories consumed for day #3: 1000
Enter calories burned for day #3: 1400
Enter calories consumed for day #4: 2000
Enter calories burned for day #4: 1600
Enter calories consumed for day #5: 1000
Enter calories burned for day #5: 1200
Enter calories consumed for day #6: 2000
Enter calories burned for day #6: 1400
Enter calories consumed for day #7: 1000
Enter calories burned for day #7: 1400
You consumed a total of 10,000 calories this week.
You burned a total of 10,200 calories this week.
You consumed an average of 1,428.57 calories a day.
You burned an average of 1,457.14 calories a day.
Your net weekly gain/loss were -.067 pounds.
Hint: You may need to use System.out.printf to get the correct formatting of the numbers.
System.
out.print("Total Calories Consumed are: ");
System.
out.printf("%,.2f
", totalAmount);
System.
out.print("Total Calories Burned are: ");
System.
out.printf("%,.2f
", totalBurned)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions