Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class UnitConversions
  5. {
  6.  
  7.     public static void main(String[] args)
  8.     {
  9.         Scanner in = new Scanner(System.in);
  10.        
  11.         double unitTotal = 0;
  12.        
  13.         System.out.println("Please enter a value:");
  14.         String unitValue = in.nextLine();
  15.         double doubleUnitValue = Double.valueOf(unitValue);
  16.        
  17.         System.out.println("Please enter a conversion type: \nGL for Gallons to Liters \nIC for Inches to Centimeters \nPK for Pounds to Kilograms \nMK for Miles to Kilometers");
  18.         String unitType = in.nextLine();
  19.    
  20.         if(unitType == "GL")
  21.         unitTotal = doubleUnitValue * 3.79;
  22.         System.out.println(doubleUnitValue + " Gallons = " + unitTotal + " Liters.");
  23.         //if(unitType == "IC")
  24.             //unitTotal =
  25.        
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement