Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Partial Weight Converter
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WeightConverter
{
public static void main(String args[])throws IOException
{
while(true)
{
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
{
System.out.println("Please Enter your choice:");
System.out.println("1: Convert lbs to kilos");
System.out.println("2: Convert kilos to lbs");
System.out.println("3: Exit");
int choice = Integer.parseInt(bufferedReader.readLine());
switch(choice)
{
case 1 :
System.out.println("Enter weight in lbs");
String input=bufferedReader.readLine();
double lbs=Double.parseDouble(input);
while(lbs<0)
{
System.out.println("Please enter a positive number");
lbs=Integer.parseInt(bufferedReader.readLine());
}
double kilos=(lbs/2.2);
System.out.println("lbs = " + kilos + " kilos");
break;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.