Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a flow chart for the following java program //Group Project import java.util.Scanner; //declaring our class public class CalorieConsumption { //declaring variables public static int

Create a flow chart for the following java program

//Group Project import java.util.Scanner; //declaring our class public class CalorieConsumption { //declaring variables public static int fat; public static int carbs; public static int protein; public static int water; //setting user input to an object called fat public int getFat () { return fat; } //setting user input to an object called protein public int getProtein () { return protein; } //setting user input to an object called carbs public int getCarbs () { return carbs; } //setting user input to an object called water public int getWater () { return water; } // fat intake method public static String compareFat(int fat) { if (fat < 44) { return "Consume more fat!"; } else if (fat >= 78) { return "Reduce Fat Intake!"; } else { return "Good Job!"; } } // protein intake method public static String compareProtein(int protein) { if (protein < 46) { return "Consume more protein!"; } else { return "Good Job!"; } } // carbs intake method public static String compareCarbs(int carbs) { if (carbs < 225) { return "Consume more carbs!"; } else if (carbs >= 325) { return "Reduce Carbs Intake!"; } else { return "Good Job!"; } } // water intake method public static String compareWater(int water) { if (water < 72) { return "Consume more water!"; } else { return "Good Job!"; } } //main method public static void main(String[] args) { Scanner sc=new Scanner(System.in); //initializing variables used in program int calorie,goal,hours; double height,weight; double sum = 0; //welcoming user System.out.println("Hello!!"); //Getting user weight System.out.println("Enter in current body weight in pounds: "); weight=sc.nextInt(); //getting water intake System.out.println("Enter water intake in oz for the day: "); int water=sc.nextInt(); //getting calorie intake total System.out.println("Type -1 to exit Enter in consumption of calories: "); calorie=sc.nextInt(); //loop for calorie consumption while (calorie != -1) { sum+=calorie; System.out.println("Type -1 to stop Enter in consumption of calories: "); calorie=sc.nextInt(); } //calories burned int exoption = 0; double caloriesburned = 0; while (exoption != -1) { System.out.println("Select which type of exercise 1 - Weight Lifting 2 - Cardio 3 - Steps/Walking Enter -1 to stop :"); exoption=sc.nextInt(); switch (exoption) { case 1:System.out.println("Enter hours of exercise: "); hours=sc.nextInt(); caloriesburned = (hours/2)*(weight/1.2); break; case 2:System.out.println("Enter hours of exercise: "); hours=sc.nextInt(); caloriesburned = hours*600; break; case 3:System.out.println("Enter hours of exercise: "); hours=sc.nextInt(); caloriesburned = hours*350; break; } caloriesburned+=caloriesburned; } //user input for carbs System.out.println("Enter in consumption of carbs in grams: "); int carbs=sc.nextInt(); //user input for protein System.out.println("Enter in consumption of protein in grams: "); int protein=sc.nextInt(); //user input for fat System.out.println("Enter in consumption of fat in grams: "); int fat = sc.nextInt(); //printing user results //header for table System.out.println("- User Summary -"); //Separator System.out.println("--------------------------------------------------"); //printing results System.out.printf(" You have consumed %.2f calories ",sum); System.out.printf("You have burned %.2f calories ",caloriesburned); //printing water and calling method to determine if user is drinking enough water System.out.printf(" You have consumed %d oz of water \t",water); System.out.printf(compareWater(water)); //printing carbs and calling method to determine if user is eating enough carbs System.out.printf(" You have consumed %d grams of Carbs \t",carbs); System.out.printf(compareCarbs(carbs)); //printing protein and calling method to determine if user is eating enough protein System.out.printf(" You have consumed %d grams of Protein \t",protein); System.out.printf(compareProtein(protein)); //printing fat and calling method to determine if user is eating enough fat System.out.printf(" You have consumed %d grams of Fat \t",fat); System.out.printf(compareFat(fat)); //closing braces } }

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

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago