Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


David Ferguson
Weight loss
1 Answer(s)      3 years and a month 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 } }


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
Weight loss by Ayurveda
Weight loss by Ayurveda There are many ways to loose weight but there has been... weight. Ayurveda weight loss method includes a balanced diet, Yoga and meditation. There are no medicines involved and there are no side effects to weight loss
Weight Loss Surgery Side Effects
Weight Loss Surgery Side Effects Though Weight loss surgery also known... Bariatric surgery or Weight loss surgery. The size of stomach is reduced... and stomach cramping is another side effect of weight loss surgery. In some
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
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
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
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
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
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... the font-family: g.drawString(differentFonts[j],p,q); Here...(differentFonts[j],p,q);   }   }   public static 
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... on MOM architecture. BEA Tuxedo/Q,  Sun Java System Messaging Server, IBM
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
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
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
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
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
Java swing
Java swing  Does Swing contains any heavy weight component
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
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
spring - Spring
spring  how spring is light weight? please tell me this i want to know
Advertisements
 

 

 

DMCA.com