David Ferguson
Weight loss
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners

Is anybody able to help me. I am wanting to build a weightloss programme

If anyone could help that would be great

//calculate and output weight loss given time spent on activities import java.util.*;

public class WeightLoss { public static void main (String args[]) { //create Scanner for input //declare constants for calories per activity and calories burnt //prompt for name and input response //prompt for hours spent exercising and input responses //determine first name //calculate calories burnt //calculate weight loss //output name, calories burnt and weight loss } }

View Answers

October 25, 2011 at 3:14 PM


import java.util.*;
public class WeightLoss{ 

    public static void main (String args[]){ 

    Scanner sc = new Scanner(System.in);
    final int CYCLING_CALS = 200;
    final int RUNNING_CALS = 475;
    final int SWIMMING_CALS = 275;

    System.out.print("Enter Name: ");
    String name=sc.nextLine();


    System.out.print("Cycling hours: ");
    int cycling = sc.nextInt();

    System.out.print("Running hours: ");
    int running = sc.nextInt();

    System.out.print("Swimming hours: ");
    int swimming = sc.nextInt();

    int caloriesFromCycling = cycling * CYCLING_CALS;
    int caloriesFromRunning = running * RUNNING_CALS;
    int caloriesFromSwimming = swimming * SWIMMING_CALS;

    double calories = caloriesFromSwimming + caloriesFromRunning + caloriesFromCycling;
    double poundsLost = calories / 3500;
    System.out.println();
    System.out.println("Name is "+name);
    System.out.println ("total calaries lost is " + poundsLost);
    System.out.println("total calories burnt is " + calories);

    }
    }









Related Pages:
Weight loss
Weight loss   Is anybody able to help me. I am wanting to build... and output weight loss given time spent on activities import java.util.*; public... //calculate calories burnt //calculate weight loss //output
Weight Loss
Weight Loss Here we are providing complete information on Obesity and weight loss. This information will guide you in finding the right way in weight loss.... We are also discussing about Weight Loss surgery. There are many advantages
Weight loss by Ayurveda
Weight loss by Ayurveda This article explains you the importance of Ayurveda in weight loss. Using Ayurvedic principals you can lose your weight easily... following things for weight loss: Obesity Massage Obesity Reduction
Weight Loss Surgery Side Effects
Weight Loss Surgery Side Effects This article we are discussing the side effects of weight loss surgery. What kind of side effects can occur after the surgery? Will a patient gain weight back? If you are thinking that Weigh Loss
Lose Weight Surgery
Lose Weight Surgery This article discusses about weight loss surgery and how it is useful in reducing weight. These days weight loss surgery is successfully... even after dieting you can find good doctor and go for weight loss surgery
Surgery to lose weight
is now opting for the weight loss surgery to reduce the weight. Weight loss surgery is also one of the options for the weight loss. Surgery to lose weight.... You should go for the diet control and Ayurvedic medicines for the weight loss
How much water to drink a day to lose weight?
in controlling obesity? Read more on Weight Loss - Natural way of losing weight...How Much Water To Drink a Day To Lose Weight? There is no dearth of reasons..., as this will help in controlling weight. Drinking  water before and after every meal
possible loss of precision
possible loss of precision  { int amount=(int)depositAmount; switch (depositAmount) { case(depositAmount<=depAmount1... is" +intrest); } i have possible loss of precision as my error
possible loss of precision error
possible loss of precision error  how do i fix this error " possible loss of precision found int required char ch = input.read()" this is the code import java.io.InputStreamReader; import java.io.IOException; class Test1
can a volatile memory loss data on power cut
can a volatile memory loss data on power cut  Can a volatile memory loss ache and main memory content on power cut?   In Volatile, Cache and main memory will lose their contents when the power is off
Programming: Body Mass Index - Dialog
of your weight for your height. It is calculated as weight in kilograms divided... for their height. Convert it to a double. Ask the user for their weight. Convert it to a double. Use the formula BMI = weight / (height * height) to calculate the BMI
Simple Font Paint Example
, appearance, weight, and spacing of a character. It is the combination of pitch
Display Different Fonts
the design, size, appearance, weight, and spacing of a character
Java Interview Questions - Page 9
Java Interview Questions - Page 9       Question: Which package has light weight components... are called light weight components. Question: What
PaperClips
PaperClips       A simple, light weight, extensible Java printing plug-in for SWT. PaperClips hides the complexity of laying out and rendering documents on the printer
Why effective fleet management is necessary?
In case you are wondering why effective fleet management is necessary and what will be loss one has to face in case they neglect or give less attention in managing their fleet, than beware the negligence has made man country suffer huge
Message Driven Beans
Message Driven Beans       Message driven beans are the light weight components used for communication. In message driven beans the messaging service is in asynchronous mode because
Disadvantages Of Obesity
Exercise can help you in controlling obesity? Read more on Weight Loss - Natural..., it its essential to keep your body weight under control. Causes of Obesity... Exercise to control your weight. Hereditary Metabolic disorders
Protecting Your iPad Has Never Been Easier
Protecting Your iPad Has Never Been Easier Since its release early in 2010, the iPad has been flying off the shelves in stores all over the world. The amazing new features and light weight design have been largely responsible
restrictedbar
{ private int weight; private int price; Bar() { } Bar(int weight,int price) { this.weight=weight; this.price=price; } public void setweight(int weight) { this.weight=weight; } public void setprice(int price
restrictedpowder
{ private int weight; private int price; Powder() { } Powder(int weight,int price) { this.weight=weight; this.price=price; } public void setweight(int weight) { this.weight=weight; } public void setprice
Java swing
Java swing  Does Swing contains any heavy weight component
cp and sp
cp and sp  design a gui application to accept the cost price and selling price from the user in two textfields and then calculate the profit or loss occured
Converting PDF in to XML
Converting PDF in to XML  I have to convert PDF into XMl without any loss in text. Please suggest sth good
image Processing
image Processing  Please give Me a JPEG or GIf "LOSS LESS" Image Compression and Decompression Source Code Please Help Me I don't want links Kindly help me Compression ratio not matter
Business uses of Fleet Management
of the vehicle reach on time to its destination the owner is not in loss. In fleet... the competition every owner must give it deserving weight-age
spring - Spring
spring  how spring is light weight? please tell me this i want to know
Java BMI code
, stone and pounds which represents someone?s weight and returns that weight in pounds calculateBMI( ) takes 2 integer parameters, height in inches and weight in pounds and returns the BMI using the formula: weight * 703 / height2 The main
Java simple question - Java Beginners
. Each also has a maximum weight. Assign the max weight limit to each truck... the user for a truck number and the loaded weight. Display a message indicating whether... weight = 30K. Truck 5 Max = 40K weight = 35K. Truck 6 Max = 25K weight = 27K
help today plz:( - Java Interview Questions
the weight of a package in pounds, and then outputs the weight of the backage...: import java.util.*; class Weight{ public static void main(String[] args){ Scanner input=new Scanner(System.in); System.out.println("Enter weight
I wonder - Java Beginners
. Attribute weight ii. Attribute height iii. A method to determine number...) of a person. For your information, a person needs 19 calories per pound of body weight while the BMI is used to calculate the risk of weight-related health problems
java - Java Beginners
. Therefore AWT is heavy weight component and swing is light weight component. 3) Light weight components have transparent pixels where as heavy weight is always opaque. 4) Light weight components are non-rectangular whereas Heavy weight
java program for string tokenzing and parsing
java program for string tokenzing and parsing  String s="height=128 weight=22 gender=male"; i need to convert this into height="128" weight="22" gender="male" normally if we print "hello" means we use System.out.println("\"Hello
java program for string tokenzing and parsing
java program for string tokenzing and parsing  String s="height=128 weight=22 gender=male"; i need to convert this into height="128" weight="22" gender="male" normally if we print "hello" means we use System.out.println("\"Hello
Java Coding - Java Beginners
a weight and an integer that represents a zip code and returns a double value... and getOtherShipping depending on the value of shippingMethod. Assume that the weight and zip code values are stored in variables named weight and zipCode. Store
hi.. please give me a java coding for the following question
Mass Index(BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters... weight 24-29 overweight 29 â?? 35
Attendance Generation - JSP-Servlet
no forwarding of leaves for next month otherwise (no loss of pay) 2 if i used more than 2 leaves no forwarding of leaves for next month but loss of pay should
Java Coding - Java Beginners
another if/else statement that tests the value of a double variable named weight. If the value of weight is less than or equal to 5, set a double variable named shippingBase to 4.95. If weight is greater than 5 and less than or equal to 10
how to do gui
= new JFrame(); String itemName = ""; double weight = 0.0; double... = JOptionPane.showInputDialog(frame, "Enter item name:"); //weight = Double.parseDouble(JOptionPane.showInputDialog(frame, "Enter item weight
Java Coding - Java Beginners
method named getUPSShipping that accepts a double value named weight... of a double variable named shippingCost based on the weight and zipCode values..., this method should set shippingCost to 4.95 if the weight is less than or equal to 5
difference between applet and swings
the methods that are written in Java. Therefore AWT is heavy weight component and swing is light weight component. 3) Light weight components have transparent pixels where as heavy weight is always opaque. 4) Light weight components are non
object oriented program.. - Java Beginners
that contains instance variables horsepower, weight, zeroTo60, and milesPerGal. The value of zeroTo60 (in second) is determined by the formula zeroTo60 = weight/horsepower/0.7 where horsepower can range from 200 to 700 hp, and weight can range from
difference - Applet
weight component and swing is light weight component. 3) Light weight components have transparent pixels where as heavy weight is always opaque. 4) Light weight components are non-rectangular whereas Heavy weight components
Object with different data types
" object that can contain String "name", String "ID", double "weight" and Date...; double weight; public Patient(String name, String id, double weight...; this.weight = weight; } public String getName() { return name
Switch case in Jsp page
; </tr> <tr> <td>Enter Weight :</td> <td><input type="text" name="weight"/></td> </tr> <tr> <td>... it as.. If user's distance is between 200km its weight should multiply by 2
Article Writing Services,Article Writing Outsourcing India,Affordable Article Writing Services
Planning Weight Loss Wine and Spirits Psychology Work Life Balance Hobbies... Cancer Depression Diabetes Hair Loss Multiple Sclerosis

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.