• 10-12-2012, 06:05 PM

calculate a user’s weight loss based on the amount of exercise they take
user specifies full name and hours spent cycling, running and swimming
output first name, total calories burnt and pounds lost

cycling 200
running 475
swimming 275

person loses 1 pound for every 3500 calories burnt

iv been given headings i should use to help write the programme which are

//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

now iv had a go at writing the programme but could someone please help me out with finishing any of the programme under the certain headings. heres what iv got so far -

(CODE)

import java.util.*;

public class weightloss
{
public static void main(String[] args)
{

//create Scanner for input
Scanner sc = new Scanner(System.in);

//declare constants for calories per activity and calories burnt
final int cycling_cal = 200;
final int running_cal = 475;
final int swimming_cal = 275;

//prompt for name and input response
System.out.print("Cycling Cals: ");
int cycling = sc.nextInt();
System.out.print("Running Cals: ");
int running = sc.nextInt();
System.out.print("Swimming Cals: ");
int swimming = sc.nextInt();

//promptfor hours spent exercising and input response
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();
//determine first name

//calculate calories burnt
int total_cal = (Cycling * cycling_cal) + (Running * running_cal) + (Swimming * swimming_cal);

//calculate weight loss
int Pounds_lost = total_cal / 3500;

//output name, calories burnt and weight loss

System.out.println(total_cal + Pounds_lost);

(CODE)

• 10-12-2012, 06:51 PM
KevinWorkman
What exactly are you stuck on? Does this compile? Also, please use the code tags when posting code, otherwise your code is pretty hard to read. You can go back and edit your post to add them.
• 10-12-2012, 07:04 PM