Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Program that simulates a cash register for a Gas station (GasXXXX)*/
- import java.util.Scanner; class GasEmUpAndGo_Smaller_ver2 //Name of Program
- {
- public static void main ( String[] args )
- { //Variables for user input
- double litre=0.0,subtotal=0.0;//How many litres does the user want? | Subtotal Before tax
- String service= "";//Does the User wants a Full Service?
- Scanner scan = new Scanner( System.in );//Scanner is called
- System.out.println("Do you want Full Service? (yes or no).");
- service = scan.nextLine();//Ask user if he/she wants full service
- System.out.println("Enter the amount of litre you wish to buy.");
- litre = scan.nextDouble();//Litres are entered
- if (service.equalsIgnoreCase("yes"))//Service Wanted (Full service)
- {
- service= "";//Clear String
- System.out.println("Enter the Gas Type.(bronze or silver or gold)");
- service = scan.next();//Gastype entered
- //Gas Part | Logic Starts
- if (service.equalsIgnoreCase("bronze"))//Check if user input and the string "bronze" are true (Matching)
- subtotal = (1.28) * litre;//Service price is added to Org. Value
- else if (service.equalsIgnoreCase("silver"))//Check if user input and the string "sliver" are true (Matching)
- subtotal = (1.34) * litre;//Service price is added to Org. Value
- else//Last Option is Gold
- subtotal = (1.48) * litre;//Service price is added to Org. Value
- /*Going to use "service" for a new purpose*/service ="";//Clear String
- System.out.println("Do you want a Carwash Service? (yes or no).");
- service = scan.next(); //See if the user wants a carwash?
- if(service.equalsIgnoreCase("yes"))//Carwash Part | Logic Starts | += means that <value> is added to the subtotal
- {
- System.out.println("Enter Carwash Type.(basic or full or supreme!)");
- service = scan.next();//Enter Carwash Type
- if (service.equalsIgnoreCase("basic"))//Check if user input and the string "basic" are true (Matching)
- {
- if (litre >= 25) //Check if User bought At Least 25 litres, if so DISCOUNT <3
- subtotal += 5.99;//Discount $2 when litres are at lease 25
- else
- subtotal += 7.99;//Org. Price
- }
- else if (service.equalsIgnoreCase("full"))//Check if user input and string "full" are true (Matching)
- {
- if (litre >= 25) //Check if User bought At Least 25 litres, if so DISCOUNT <3
- subtotal += 7.99;//Discount $2 when 25 litres are bought
- else
- subtotal += 9.99; //Org. Price
- }
- else//Last Option is supreme
- {
- if (litre >= 25) //Check if User bought At Least 25 litres, if so DISCOUNT <3
- subtotal += 10.99;//Discount $2 when 25 litres are bought
- else
- subtotal += 12.99;//Org. Price
- }
- }
- /*Going to use "service" for new purpose*/service ="";//Clear String
- System.out.println("Do you want a Oil Change? (yes or no).");
- service = scan.next(); //See if the user wants an Oil Change
- if (service.equalsIgnoreCase("yes"))
- subtotal += 15.99;//Discounted with 20% if user had full service on gas
- service ="";//Clear String
- System.out.println("Do you want a Fluid Check? (yes or no).");
- service = scan.next(); //See if the user wants a Fluid Check
- if(service.equalsIgnoreCase("yes"))
- subtotal += 8;//Discounted with 20% if user had full service on gas
- service="";//Clear String
- System.out.println("Do you want a Tire Check? (yes or no).");
- service = scan.next(); //See if the user wants a Tire Check
- if (service.equalsIgnoreCase("yes"))
- subtotal += 3.2;//Discounted with 20% if user had full service on gas
- } //============================================================================================
- else// Non-Service ex. does not want full service when buying gas
- {System.out.println("Enter the Gas Type.(bronze or silver or gold)");
- service = scan.next();//Gastype entered
- //Gas Part | Logic Starts
- if (service.equalsIgnoreCase("bronze"))//Check if user input and the string "bronze" are true (Matching)
- subtotal = (1.22) * litre;//Org. Price
- else if (service.equalsIgnoreCase("silver"))//Check if user input and the string "sliver" are true (Matching)
- subtotal = (1.30) * litre;//Org. Price
- else//Last Option is Gold
- subtotal = (1.44) * litre;//Org. Price
- /*Going to use "service" for new purpose*/service ="";//Clear String
- System.out.println("Do you want a Carwash Service? (yes or no).");
- service = scan.next(); //See if the user wants a carwash
- //Carwash Part | Logic Starts | += means that <value> is added to the subtotal
- if(service.equalsIgnoreCase("yes"))
- {
- System.out.println("Enter Carwash Type.(basic or full or supreme )");
- service = scan.next();//Enter Carwash Type
- if (service.equalsIgnoreCase("basic"))//Check is either if user input and the string "basic" are true (Matching)
- {
- if (litre >= 25) //Check if User bought At Least 25 litres, if so DISCOUNT <3
- subtotal += 5.99;//Discount $2 when 25 litres are bought
- else
- subtotal += 7.99;//Org. Price
- }
- else if (service.equalsIgnoreCase("full"))//Check is either if user and string "full" are true (Matching)
- {
- if (litre >= 25) //Check if User bought At Least 25 litres, if so DISCOUNT <3
- subtotal += 7.99;//Discount $2 when 25 litres are bought
- else
- subtotal += 9.99;//Org. Price
- }
- else//Last Option is supreme
- {
- if (litre >= 25) //Check if User bought At Least 25 litres, if so DISCOUNT <3
- subtotal += 10.99;//Discount $2 when 25 litres are bought
- else
- subtotal += 12.99;//Org. Price
- }
- }
- /*Going to use "service" for new purpose*/service ="";//Clear String
- System.out.println("Do you want a Oil Change? (yes or no).");
- service = scan.next(); //See if the user wants an Oil Change
- if (service.equalsIgnoreCase("yes"))
- subtotal += 19.99;//Org. Price
- service ="";//Clear String
- System.out.println("Do you want a Fluid Check? (yes or no).");
- service = scan.next(); //See if the user wants a Fluid Check
- if(service.equalsIgnoreCase("yes"))
- subtotal += 10;//Org. Price
- service="";//Clear String
- System.out.println("Do you want a Tire Check? (yes or no).");
- service = scan.next(); //See if the user wants a Tire Check
- if (service.equalsIgnoreCase("yes"))
- subtotal += 4;//Org. Price
- }
- //Prints Out: Total before Tax (Subtotal) | Tax | Total with tax
- System.out.println("Subtotal is: " + subtotal + "\n" + "HST is: 13%" + "\n" + "Total is: "+ (subtotal*1.13) );
- }
- }
Add Comment
Please, Sign In to add comment