Guest User

Untitled

a guest
Jun 25th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.95 KB | None | 0 0
  1. /*  Program that simulates a cash register for a Gas station (GasXXXX)*/
  2. import java.util.Scanner; class GasEmUpAndGo_Smaller_ver2 //Name of Program
  3. {    
  4.   public static void main ( String[] args )    
  5.   { //Variables for user input
  6.     double litre=0.0,subtotal=0.0;//How many litres does the user want? | Subtotal Before tax
  7.     String service= "";//Does the User wants a Full Service?
  8.     Scanner scan = new Scanner( System.in );//Scanner is called
  9.    
  10.     System.out.println("Do you want Full Service? (yes or no).");
  11.     service = scan.nextLine();//Ask user if he/she wants full service
  12.     System.out.println("Enter the amount of litre you wish to buy.");
  13.     litre = scan.nextDouble();//Litres are entered
  14.     if (service.equalsIgnoreCase("yes"))//Service Wanted (Full service)
  15.     {
  16.       service= "";//Clear String
  17.       System.out.println("Enter the Gas Type.(bronze or silver or gold)");
  18.       service = scan.next();//Gastype entered
  19.       //Gas Part | Logic Starts
  20.       if (service.equalsIgnoreCase("bronze"))//Check if user input and the string "bronze" are true (Matching)
  21.         subtotal = (1.28) * litre;//Service price is added to Org. Value
  22.       else if (service.equalsIgnoreCase("silver"))//Check if user input and the string "sliver" are true (Matching)
  23.         subtotal = (1.34) * litre;//Service price is added to Org. Value
  24.       else//Last Option is Gold
  25.         subtotal = (1.48) * litre;//Service price is added to Org. Value
  26.       /*Going to use "service" for a new purpose*/service ="";//Clear String
  27.       System.out.println("Do you want a Carwash Service? (yes or no).");
  28.       service = scan.next(); //See if the user wants a carwash?
  29.       if(service.equalsIgnoreCase("yes"))//Carwash Part | Logic Starts | += means that <value> is added to the subtotal
  30.       {
  31.         System.out.println("Enter Carwash Type.(basic or full or supreme!)");
  32.         service = scan.next();//Enter Carwash Type
  33.         if (service.equalsIgnoreCase("basic"))//Check if user input and the string "basic" are true (Matching)
  34.         {
  35.           if (litre >= 25)   //Check if User bought At Least 25 litres, if so DISCOUNT <3
  36.             subtotal += 5.99;//Discount $2 when litres are at lease 25
  37.           else
  38.             subtotal += 7.99;//Org. Price
  39.         }
  40.         else if (service.equalsIgnoreCase("full"))//Check if user input and string "full" are true (Matching)
  41.         {
  42.           if (litre >= 25)    //Check if User bought At Least 25 litres, if so DISCOUNT <3
  43.             subtotal +=  7.99;//Discount $2 when 25 litres are bought
  44.           else
  45.             subtotal += 9.99; //Org. Price
  46.         }
  47.         else//Last Option is supreme
  48.         {
  49.           if (litre >= 25)    //Check if User bought At Least 25 litres, if so DISCOUNT <3
  50.             subtotal += 10.99;//Discount $2 when 25 litres are bought
  51.           else
  52.             subtotal += 12.99;//Org. Price
  53.         }
  54.       }
  55.       /*Going to use "service" for new purpose*/service ="";//Clear String
  56.       System.out.println("Do you want a Oil Change? (yes or no).");
  57.       service = scan.next(); //See if the user wants an Oil Change
  58.       if (service.equalsIgnoreCase("yes"))
  59.         subtotal += 15.99;//Discounted with 20% if user had full service on gas
  60.       service ="";//Clear String
  61.       System.out.println("Do you want a Fluid Check? (yes or no).");
  62.       service = scan.next(); //See if the user wants a Fluid Check
  63.       if(service.equalsIgnoreCase("yes"))
  64.         subtotal += 8;//Discounted with 20% if user had full service on gas
  65.       service="";//Clear String
  66.       System.out.println("Do you want a Tire Check? (yes or no).");
  67.       service = scan.next(); //See if the user wants a Tire Check
  68.       if (service.equalsIgnoreCase("yes"))
  69.         subtotal += 3.2;//Discounted with 20% if user had full service on gas
  70.     } //============================================================================================
  71.     else// Non-Service ex. does not want full service when buying gas
  72.     {System.out.println("Enter the Gas Type.(bronze or silver or gold)");
  73.       service = scan.next();//Gastype entered
  74.       //Gas Part | Logic Starts
  75.       if (service.equalsIgnoreCase("bronze"))//Check if user input and the string "bronze" are true (Matching)
  76.         subtotal = (1.22) * litre;//Org. Price
  77.       else if (service.equalsIgnoreCase("silver"))//Check if user input and the string "sliver" are true (Matching)
  78.         subtotal = (1.30) * litre;//Org. Price
  79.       else//Last Option is Gold
  80.         subtotal = (1.44) * litre;//Org. Price
  81.       /*Going to use "service" for new purpose*/service ="";//Clear String
  82.       System.out.println("Do you want a Carwash Service? (yes or no).");
  83.       service = scan.next(); //See if the user wants a carwash
  84.       //Carwash Part | Logic Starts | += means that <value> is added to the subtotal
  85.       if(service.equalsIgnoreCase("yes"))
  86.       {
  87.         System.out.println("Enter Carwash Type.(basic or full or supreme )");
  88.         service = scan.next();//Enter Carwash Type
  89.         if (service.equalsIgnoreCase("basic"))//Check is either if user input and the string "basic" are true (Matching)
  90.         {
  91.           if (litre >= 25)   //Check if User bought At Least 25 litres, if so DISCOUNT <3
  92.             subtotal += 5.99;//Discount $2 when 25 litres are bought
  93.           else
  94.             subtotal += 7.99;//Org. Price
  95.         }
  96.         else if (service.equalsIgnoreCase("full"))//Check is either if user and string "full" are true (Matching)
  97.         {
  98.           if (litre >= 25)    //Check if User bought At Least 25 litres, if so DISCOUNT <3
  99.             subtotal +=  7.99;//Discount $2 when 25 litres are bought
  100.           else
  101.             subtotal += 9.99;//Org. Price
  102.         }
  103.         else//Last Option is supreme
  104.         {
  105.           if (litre >= 25)    //Check if User bought At Least 25 litres, if so DISCOUNT <3
  106.             subtotal += 10.99;//Discount $2 when 25 litres are bought
  107.           else
  108.             subtotal += 12.99;//Org. Price
  109.         }
  110.       }
  111.       /*Going to use "service" for new purpose*/service ="";//Clear String
  112.       System.out.println("Do you want a Oil Change? (yes or no).");
  113.       service = scan.next(); //See if the user wants an Oil Change
  114.       if (service.equalsIgnoreCase("yes"))
  115.         subtotal += 19.99;//Org. Price
  116.       service ="";//Clear String
  117.       System.out.println("Do you want a Fluid Check? (yes or no).");
  118.       service = scan.next(); //See if the user wants a Fluid Check
  119.       if(service.equalsIgnoreCase("yes"))
  120.         subtotal += 10;//Org. Price
  121.       service="";//Clear String
  122.       System.out.println("Do you want a Tire Check? (yes or no).");
  123.       service = scan.next(); //See if the user wants a Tire Check
  124.       if (service.equalsIgnoreCase("yes"))
  125.         subtotal += 4;//Org. Price
  126.     }
  127.     //Prints Out: Total before Tax (Subtotal) | Tax | Total with tax
  128.     System.out.println("Subtotal is: " + subtotal + "\n" + "HST is: 13%" + "\n" + "Total is: "+ (subtotal*1.13) );
  129.   }  
  130. }
Add Comment
Please, Sign In to add comment