Advertisement
ssss_reapz

Untitled

Mar 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. package switchConvert;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class switchConvert {
  6.  
  7.     public static void main(String[] args) {
  8.         import java.util.Scanner;
  9.  
  10.         public class convert {
  11.  
  12.             public static void main(String[] args) {
  13.                
  14.             double first;
  15.             double second;
  16.             String choice = nextLine;
  17.            
  18.            
  19.            
  20.             Scanner scan = new Scanner (System.in);
  21.             System.out.println ("Please select an option 1 - 4:");
  22.             System.out.println ("1(GL): Gallons to Liters");
  23.             System.out.println ("2(IC): Inch to Centimeter");
  24.             System.out.println ("3(PK): Pound to Kilogram");
  25.             System.out.println ("4(MK): Mile to Kilogram");
  26.             choice = scan.nextLine().toUpperCase();
  27.            
  28.            
  29.             switch(choice.nextLine()) {
  30.             case GL:
  31.                 System.out.println ("Enter amount of Gallons: ");
  32.                 first = scan.nextDouble();
  33.                 second = first * 3.78541178;
  34.                 System.out.println("there are "+ second +" liters in " +first+" gallons");
  35.             break;
  36.            
  37.             case IC:
  38.                 System.out.println ("Enter amount of Inches: ");
  39.                 first = scan.nextDouble();
  40.                 second = first * 2.5;
  41.                 System.out.println("there are "+ second +" centimeters in " +first+" inches");
  42.                 break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement