Question: Your mission... A gas station credits customers with $0.05 (5 cents) towards a car wash for every litre of regular gasoline purchased and $0.06


Your mission... A gas station credits customers with $0.05 (5 cents) towardsa car wash for every litre of regular gasoline purchased and $0.06

Your mission... A gas station credits customers with $0.05 (5 cents) towards a car wash for every litre of regular gasoline purchased and $0.06 (6 cents) for every litre of premium gasoline purchased. Your job is to write a program that will calculate how many car washes have been earned by a customer. Requirements Create a source code file named Your_Initials_CarWash.java. For example, if your name is Sam Turner, you would name it ST_CarWash.java. Make sure that you save your new file immediately. Now write a short program that does all of the following, in sequence: 1. Prints an explanation of the purpose of the program as shown in the screenshot below. 2. Asks the user to enter the number of litres of regular gasoline purchased as well as the number of litres of premium gasoline purchased. Each of these two values should be assigned to a variable of an appropriate type given that it will be used in calculations. Since no credit is given for part of a litre you can assume that no decimal places will be required. 3. Asks the user to enter the price of a car wash (e.g. $10.99) and assigns this to a suitable variable. 4. Asks the user to enter the model of the customer's vehicle (e.g. "2012 Toyota RAV4") and assigns this to an appropriate variable. 5. Declares a pair of constants of a suitable type called CREDIT_FOR_REGULAR which is assigned the value 0.05 and CREDIT_FOR_PREMIUM which is assigned the value 0.06. This is the credit in dollars awarded to the customer for each litre of fuel purchased. 6. Declares a suitable variable to store the total credit earned towards car washes and assigns it a value calculated using the following formula: 7. Declares another suitable variable to store the number of complete car washed earned and assigns it a 7. Declares another suitable variable to store the number of complete car washed earned and assigns it a value by dividing the total credit by the price for a wash. We don't want decimal places here so truncate the answer and store it in a variable without decimal places. 8. Declares yet another suitable variable to store the extra credit earned in excess of the complete car washes earned and assigns to it this calculated amount. For example, if a customer has earned a total credit of $23.05 and a car wash is $10.99 then 2 washes have been earned and there will be $23.05 2 x $10.99 $1.07 of credit remaining (leftover). 9. Outputs the total credit, the number of washes, the extra credit and the vehicle model using the format shown in the sample output below. For the extra credit earned, TRUNCATE ANY DECIMALS BEYOND TWO PLACES so that it reads as a proper dollar and cents amount. = Calculating the number of car washes earned based on your gas purchases... Enter the litres of regular gas purchased: 311 Enter the litres of premium gas purchased: 125 Enter the price of a car wash: $ 10.99 Enter the model of your vehicle: 2012 Toyota RAV4 Your total credit earned is $23.05. You've earned 2 car wash(es) for your 2012 Toyota RAV4. The extra credit earned is $1.07

Step by Step Solution

3.48 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Below is a simple Java program that fulfills the given requirements java import javautilScanner publ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!