Question: Weight loss



Share on Google+Share on Google+

David Ferguson
Weight loss
1 Answer(s)      5 years 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(;
    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("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
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 =" this is the code import; import; 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       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
{ 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
{ 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
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
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
Java Spring Hibernate Struts Training Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include?


Advertisement null