Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Partial Weight Converter

View gist:d75f5df8a1464877e781
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
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.