Guest User

Untitled

a guest
Jun 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.38 KB | None | 0 0
  1. /* Martin Txran
  2.  * Program that somulates a cash register for a Gas station
  3.  */
  4. import java.util.Scanner;
  5. class GasEmUpAndGo
  6. {    
  7.   public static void main ( String[] args )    
  8.   {
  9.     //Variables for Gas Type
  10.     double gas_type_bronze = 1.22;                          //Value for Bronze
  11.     double gas_type_silver = 1.3;                          //Value for Silver
  12.     double gas_type_gold = 1.44;                          //Value for Gold
  13.     double full_servce = 0.04;                           //Value for Full Service (Full service * L)
  14.     //Variable for Gas Name
  15.     String bronze = "bronze";    //Sting to compare with user input
  16.     String silver = "silver";   //Sting to compare with user input
  17.     String gold   = "gold";    //Sting to compare with user input
  18.     //Variable for user input
  19.     String gas_name_input;
  20.     double litre = 0.0;
  21.     boolean service = true;
  22.     String service_input;
  23.     //Variable for Totals & tax
  24.     double total = 0;
  25.     double tax = 0;
  26.    
  27.     Scanner scan = new Scanner( System.in );
  28.     System.out.println("Enter the Gas Type.");
  29.     gas_name_input = scan.nextLine();                      //Money in bank account entered
  30.     System.out.println("Do you want Full Service (true or false).");
  31.     service_input = scan.nextLine();                      //Money in bank account entered
  32.     System.out.println("Enter the amount of litre you wish to buy.");
  33.     litre = scan.nextDouble();                            //Money in savings account entered
  34.    
  35.     if (bronze == gas_name_input )//Check is either if user and string "bronze" are true (Matching)
  36.     {
  37.       if (service_input == service)
  38.       {
  39.         total = (gas_type_bronze + full_service) * litre;
  40.       }
  41.       else
  42.         total = gas_type_bronze * litre;
  43.     }
  44.     if (silver == gas_name_input )//Check is either if user and string "silver" are true (Matching)
  45.     {
  46.       if (service_input == service)
  47.       {
  48.         total = (gas_type_silver + full_service) * litre;
  49.       }
  50.       else
  51.         total = gas_type_silver * litre;
  52.     }
  53.     if (gold == gas_name_input )//Check is either if user and string "gold" are true (Matching)
  54.     {
  55.       if (service_input == service)
  56.       {
  57.         total = (gas_type_gold + full_service) * litre;
  58.       }
  59.       else
  60.         total = gas_type_gold * litre;
  61.     }
  62.     System.out.println("Subtotal is: " + total)
  63.    
  64.   }  
  65. }
Add Comment
Please, Sign In to add comment