Created
July 14, 2014 23:58
-
-
Save anonymous/d75f5df8a1464877e781 to your computer and use it in GitHub Desktop.
Partial Weight Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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