subject

Java Eclipse Homework Calories Package : chall12A
Class : Calories

Use a “while loop” in the code to solve the following problem:

Over a 14-day period, calculate the total number of calories that the user consumed.
Use the following information to create the necessary code. You will use a while loop in this code.

1. The following variables will need to be of type “int”:
• day
• calories
• totalCalories
1. Show a title on the screen for the program.
2. Ask the user if they want to run the program.
3. Initialize (give values) to those variables that need starting values.
4. If their answer is a capital or lowercase ‘Y’, do the following:
• Use a while loop to loop through the days.
• Ask the user for the number of calories he/she consumed on each day. Please • include the day number in your question. Example: “How many calories did you consume on day 1?”
Include the calculation to keep a running total of the calories consumed.
1. After 14 days, the code should fall out of the loop. Include a print statement that looks like this: “After 14 days, you consumed calories.” (Of course, the computer will need to fill in the total number.)
2. Include an “else” so that there is an appropriate response if the user decides not to run the program.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 16:00, eden1017
Why should characters such as / \ " ' * ; - ? [ ] ( ) ~ ! $ { } < > # @ & | space, tab, and newline be avoided in file names?
Answers: 2
image
Computers and Technology, 22.06.2019 19:20, ChaosMind
Write a program that reads a file consisting of students’ test scores in the range 0–200. it should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. output the score ranges and the number of students. (run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)
Answers: 3
image
Computers and Technology, 22.06.2019 21:50, IdkHowToDoMath
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
image
Computers and Technology, 23.06.2019 00:30, alex7078
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
You know the right answer?
Java Eclipse Homework Calories Package : chall12A
Class : Calories

Use a “while l...

Questions in other subjects:

Konu
Mathematics, 19.01.2021 20:20