Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. A gas station sells three different grades of gasoline. The retail prices are shown below.(Please use java language) Gas Grade Type Price Per Gallon

1. A gas station sells three different grades of gasoline. The retail prices are shown below.(Please use java language)

Gas Grade Type Price Per Gallon

87 Regular $2.45

89 Plus $2.89

93 Premium $3.09

Write a program that asks the user to enter the gas grade and the gallons sold, then calculates and outputs the price before tax.

The program should be menu driven, giving the user various choices:

87 - Regular

89 - Plus

93 - Premium

0 - Exit

You should use a flag-controlled or a sentinel-controlled while loop so that the program can get a series of sales data until the user enters 0. Inside the loop, a switch structure is used to help selecting a gasoline grade and displaying the price for each sale.

Your program should also calculate and display the total value of each grade of gas sold, and calculate and display the total value of all sales. The results should be formatted appropriately.

Here is a sample input/output dialog:

Welcome to "Your Friendly Gas Station"

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 87

Enter the gallons sold: 12.45

The price is $30.50 before tax.

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 96

Invalid selection (enter 87, 89, 93, or 0).

Please try again.

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 93

Enter the gallons sold: 24.9

The price is $76.94 before tax.

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 89

Enter the gallons sold: -12

Gallons sold must be greater than zero.

Try again.

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 89

Enter the gallons sold: 12

The price is $34.68 before tax.

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 87

Enter the gallons sold: 29.6

The price is $72.52 before tax.

******************************************************

Enter the gas number 87, 89, or 93 to start or 0 to exit.

87 --- Regular $2.45

89 --- Plus $2.89

93 --- Premium $3.09

0 --- Exit

Select a number: 0

Total retail value for each grade of gas sold:

Regular (87): $103.02

Plus (89): $34.68

Premium (93): $76.94

Total retail value of all sales: $214.64

Thank you for using this program!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

In what ways can confl ict enrich relationships?

Answered: 1 week ago

Question

How do listening and hearing diff er?

Answered: 1 week ago

Question

How does eff ective listening diff er across listening goals?

Answered: 1 week ago