Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Martin Txran
- * Program that somulates a cash register for a Gas station
- */
- import java.util.Scanner;
- class GasEmUpAndGo
- {
- public static void main ( String[] args )
- {
- //Variables for Gas Type
- double gas_type_bronze = 1.22; //Value for Bronze
- double gas_type_silver = 1.3; //Value for Silver
- double gas_type_gold = 1.44; //Value for Gold
- double full_servce = 0.04; //Value for Full Service (Full service * L)
- //Variable for Gas Name
- String bronze = "bronze"; //Sting to compare with user input
- String silver = "silver"; //Sting to compare with user input
- String gold = "gold"; //Sting to compare with user input
- //Variable for user input
- String gas_name_input;
- double litre = 0.0;
- boolean service = true;
- String service_input;
- //Variable for Totals & tax
- double total = 0;
- double tax = 0;
- Scanner scan = new Scanner( System.in );
- System.out.println("Enter the Gas Type.");
- gas_name_input = scan.nextLine(); //Money in bank account entered
- System.out.println("Do you want Full Service (true or false).");
- service_input = scan.nextLine(); //Money in bank account entered
- System.out.println("Enter the amount of litre you wish to buy.");
- litre = scan.nextDouble(); //Money in savings account entered
- if (bronze == gas_name_input )//Check is either if user and string "bronze" are true (Matching)
- {
- if (service_input == service)
- {
- total = (gas_type_bronze + full_service) * litre;
- }
- else
- total = gas_type_bronze * litre;
- }
- if (silver == gas_name_input )//Check is either if user and string "silver" are true (Matching)
- {
- if (service_input == service)
- {
- total = (gas_type_silver + full_service) * litre;
- }
- else
- total = gas_type_silver * litre;
- }
- if (gold == gas_name_input )//Check is either if user and string "gold" are true (Matching)
- {
- if (service_input == service)
- {
- total = (gas_type_gold + full_service) * litre;
- }
- else
- total = gas_type_gold * litre;
- }
- System.out.println("Subtotal is: " + total)
- }
- }
Add Comment
Please, Sign In to add comment