Question

I need help to write a program in Java. If a moderately active person cuts their...

I need help to write a program in Java.

If a moderately active person cuts their calorie intake by 500 calories a day, they can typically lose about 4 pounds a month. Write a program that lets the user enter their starting weight, then creates and displays a table showing what their expected weight will be at the end of each month for the next 6 months if they stay on this diet.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

class Dieting
{
   public static void main (String[] args)
   {
   Scanner input = new Scanner(System.in);
  
   System.out.println("Enter the starting weight of the person in pounds : ");
   double weight = input.nextDouble();
  
   for(int i=1;i<=6;i++)
   {
       weight = weight -4;
       System.out.println("Weight of person after "+i+" month : "+weight+" pounds");
   }
  
   }
}

Output:

  • Enter the starting weight of the person in pounds : 235
    Weight of person after 1 month : 231.0 pounds
    Weight of person after 2 month : 227.0 pounds
    Weight of person after 3 month : 223.0 pounds
    Weight of person after 4 month : 219.0 pounds
    Weight of person after 5 month : 215.0 pounds
    Weight of person after 6 month : 211.0 pounds
    
    
  • 
     

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
I need help to write a program in Java. If a moderately active person cuts their...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in 80X86 assembly language If moderately active persons cut their calorie intake by 500 calories a...

    in 80X86 assembly language If moderately active persons cut their calorie intake by 500 calories a day, they can typically lose about 4 pounds a month. Write a program that has the users enter their starting weight and then creates and displays a table showing what their expected weight will be at the end of each month for the next 6 months if they stay on this diet. please show code and output

  • Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops...

    Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations,...

  • please help i have a test tomm!! 7. In an effort to lose weight, Elizabeth decides...

    please help i have a test tomm!! 7. In an effort to lose weight, Elizabeth decides to cut her weekly calorie intake which is currently 11500 calories. She cuts 20 calories from her diet in week 1, and then each week after she decides to double the number of calories cut from the previous week a) Write a recursive formula describing Elizabeth's calorie reduction. b) Write an explicit formula describing Elizabeth's calorie reduction. c) How many calories will Elizabeth be...

  • Please write a Java program that ask the user how many beers he or she expects...

    Please write a Java program that ask the user how many beers he or she expects to consume each day, on average, as well as the average amount of money he or she spends on a single 12-ounce can of beer. Studies have shown that, on average, someone who consumes a single 12-ounce can of beer every day without compensating for the calorie intake through diet modifications or extra exercise, will gain approximately 15 pounds in one year. You can...

  • Following is my java program that i need help with. Write a program that uses a...

    Following is my java program that i need help with. Write a program that uses a JavaFX GUI that allows a user to enter a directory (folder) and then displays the number of the files in the directory. The number of files in the directory should be determined recursively.

  • Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how...

    Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how many days it will take to lose a specific number of pounds. The program will perform the following tasks: Declare variables and Named constants. Display “Welcome to <your name>’s Weight Loss Calculator” Prompt the user to enter the subject’s current weight. Prompt the user to enter the subject’s height in feet plus inches. Prompt the user to enter the subject’s age. Prompt the user...

  • Java Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a...

    Java Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a healthy, balanced diet, a grownup needs 2,250 calories a day You will write a program to track calorie intake of a person. Assignment: Calorie intake data from a person is provided in a text file named input.txt. There are arbitrary number of double values on each line, separated by spaces. The numbers represent the number of calories consumed for meals and/or snacks on a...

  • Write a java program. The cost to join a gym is: 1) Senior citizens: get a...

    Write a java program. The cost to join a gym is: 1) Senior citizens: get a 30% discount. 2.) If twelve or more months in advance are bought and paid for, a 15% discount is applied to the membership. The user enters the number of months. 3) Personal Training sessions: 20% discount on each session if more than 12 are bought. This will be a menu-driven, GUI program that determines the cost of a new membership.Using JTextField for input and...

  • Need help with java programming. Here is what I need to do: Write a Java program...

    Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1.     The input and variable value file are both text files that will be specified in...

  • Need help on following Java GUI problem: Write a program that lets a user display and...

    Need help on following Java GUI problem: Write a program that lets a user display and modify pictures. Create a window. Add four buttons so that clicking a particular button will shift the image by a small amount in the north, south, east or west direction inside the window. Add a menu bar with two menus: File and Image. The File menu should contain an Open menu item that the user can select to display JPEG and PNG files from...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT