Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public static void main(String[] args) { int inputNumber; int sum = 0; int count = 0; double average; Scanner stdin = new Scanner(System.in); System.out.print

image text in transcribed

public static void main(String[] args) { int inputNumber; int sum = 0; int count = 0; double average; Scanner stdin = new Scanner(System.in); System.out.print ("Enter the your lunch today by the calories per food item: "); inputNumber = stdin.nextInt(); while (inputNumber != 0) { sum+= inputNumber; count++; System.out.print ("Enter another calorie qty for any other food item, or 0 if there was no other food: "); inputNumber = stdin.nextInt(); 9e 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 } 27 28 29 30 31 32 33 34 35 36 } 37 38 } if (count==0) { System.out.println("You didn't have anything to eat for lunch?!"); else { average = ((double) sum) * 3; System.out.println(); System.out.println("You consumed a "+sum+" calorie lunch with just "+count+" food items!!"); System.out.println("So, theoretically you eat approximately "+average+" calories per day if your meals were consistant."); stdin.close();

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

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions