Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package switchConvert;
- import java.util.Scanner;
- public class switchConvert {
- public static void main(String[] args) {
- import java.util.Scanner;
- public class convert {
- public static void main(String[] args) {
- double first;
- double second;
- String choice = nextLine;
- Scanner scan = new Scanner (System.in);
- System.out.println ("Please select an option 1 - 4:");
- System.out.println ("1(GL): Gallons to Liters");
- System.out.println ("2(IC): Inch to Centimeter");
- System.out.println ("3(PK): Pound to Kilogram");
- System.out.println ("4(MK): Mile to Kilogram");
- choice = scan.nextLine().toUpperCase();
- switch(choice.nextLine()) {
- case GL:
- System.out.println ("Enter amount of Gallons: ");
- first = scan.nextDouble();
- second = first * 3.78541178;
- System.out.println("there are "+ second +" liters in " +first+" gallons");
- break;
- case IC:
- System.out.println ("Enter amount of Inches: ");
- first = scan.nextDouble();
- second = first * 2.5;
- System.out.println("there are "+ second +" centimeters in " +first+" inches");
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement