Question: Java question. Can someone write this code? if/else statements and methods that return values. The program will prompt the user for information about their daily

Java question. Can someone write this code?

if/else statements and methods that return values.

The program will prompt the user for information about their daily meals over the past two days, compute their total caloric intake for each day, and then determine which day was better for staying on track with their fitness goals.

For each day, we prompt for the number of meals eaten that day, the calories for each meal, and the user's level of activity.

This information is used to calculate the net caloric intake for each of the two days, the average intake for the two days, and an assessment of which day was closer to the user's goals.

Calculating Net Calories

For each of the two days, the program will ask the user how many meals they ate and their level of activity.

Total Caloric Intake

Total caloric intake is calculated as a sum of the calories all meals. The number of meals is entered by the user and may be different between days.

Estimated Caloric burn

The estimated caloric burn is defined as follows:

Not Active = 0 calories

Lightly Active = 250 calories

Active = 500 calories

Very Active = 750 calories

Output

Summary

Your program is to report the Net Caloric Intake per day and, later, the Average Caloric Intake.

The average should be rounded to one decimal places when displayed. Hint: use printf

Which day was closer to the goal?

In addition to reporting the caloric summary, the program should also produce whichever of the following messages is appropriate:

You were closer to your goal on Day 1

You were closer to your goal on Day 2

Both Day 1 and Day 2 net calories were the same

Though this analysis is most definitely not scientific (and also probably not accurate in many cases), we determine "closeness" to goal as whichever net caloric intake is mathematically closest to the calorie goal (regardless of the number of meals and activity). Thus, we will also include this disclaimer:

** DISCLAIMER: Summary results are probably wrong. I wouldn't trust them if I were you.

Other Requirements

Your solution may contain only 1 loop. This is to ensure that you are also utilizing the fact that methods can be used to repeat tasks.

You should use static methods to eliminate redundant code and to break the problem up into logical subtasks. This includes making methods that return data and methods that take data as a parameter.

Your main method should be short so that a person can easily see the overall structure of the program.

You are to introduce at least five static methods other than main to break this problem up into smaller subtasks and you should make sure that no single method is doing too much work.

In this program, none of your methods should have more than 15 lines of code in the body of the method (not counting blank lines or lines with just curly braces on them). The 15-line limitation is a special requirement for this assignment to force you to practice breaking up a program into methods.

Be sure to once again include a short comment at the beginning of your program as well as a short comment for each method describing what it does.

You do not have to perform any error checking. We will assume that the user enters numbers that are in the appropriate range.

You should avoid "chaining" long sequences of method calls together without returning to main.

Note that because this program involves both integer data and real data, you need to use appropriate type declarations (type int and calls on nextInt for integer data, type double and calls on nextDouble for real-valued data).

Output 1

This program compares your daily caloric intake for two days and determines which day was better in regards to reaching your fitness goals. What is your calorie goal for the day? > 1200 Information for Day #1: how many meals did you eat? 3 how many calories were consumed in meal 1? 350 how many calories were consumed in meal 2? 350 how many calories were consumed in meal 3? 600 -- Total caloric intake = 1300 -- what was your activity level? 1) not active 2) lightly active 3) active or 4) very active? 1 -- Estimated active caloric burn = 0 -- Information for Day #2: how many meals did you eat? 5 how many calories were consumed in meal 1? 250 how many calories were consumed in meal 2? 180 how many calories were consumed in meal 3? 400 how many calories were consumed in meal 4? 250 how many calories were consumed in meal 5? 600 -- Total caloric intake = 1680 -- what was your activity level? 1) not active 2) lightly active 3) active or 4) very active? 3 -- Estimated active caloric burn = 500 -- Day 1 Net Calories = 1300 Day 2 Net Calories = 1180 You were closer to your goal on Day 2** Average Net Calories = 1240.0 ** DISCLAIMER: Summary results are probably wrong. I wouldn't trust them if I were you.

Output 2

This program compares your daily caloric intake for two days and determines which day was better in regards to reaching your fitness goals. What is your calorie goal for the day? > 2000 Information for Day #1: how many meals did you eat? 2 how many calories were consumed in meal 1? 1120 how many calories were consumed in meal 2? 1000 -- Total caloric intake = 2120 -- what was your activity level? 1) not active 2) lightly active 3) active or 4) very active? 1 -- Estimated active caloric burn = 0 -- Information for Day #2: how many meals did you eat? 5 how many calories were consumed in meal 1? 500 how many calories were consumed in meal 2? 400 how many calories were consumed in meal 3? 540 how many calories were consumed in meal 4? 380 how many calories were consumed in meal 5? 800 -- Total caloric intake = 2620 -- what was your activity level? 1) not active 2) lightly active 3) active or 4) very active? 3 -- Estimated active caloric burn = 500 -- Day 1 Net Calories = 2120 Day 2 Net Calories = 2120 Both Day 1 and Day 2 net calories were the same** Average Net Calories = 2120.0 ** DISCLAIMER: Summary results are probably wrong. I wouldn't trust them if I were you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!