Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA please!! Write a program that will calculate and display the cost of a gasoline purchase based on the brand of gasoline, the octane

In JAVA please!!image text in transcribed

Write a program that will calculate and display the cost of a gasoline purchase based on the brand of gasoline, the octane rating and the amount purchased. Your program should first display a menu asking the user for the brand of gasoline, then prompt the user for the octane rating. Next, ask the user for the amount of gasoline in liters. Your program should not accept negative numbers for the amount of gasoline. Finally, your program should calculate and display the cost of the gasoline purchase. See Sample Output. Use the table below to calculate the cost of the gasoline. The units of measure in the table are gallons. You will need to convert liters into gallons using this conversion factor: 1 liter = 0.264172 gallons Brand of Gasoline Octane Rating Cost Per Gallon Discount 87 $2.19 Discount 88-90 $2.48 Discount 91-94 $2.71 Premium 87 $2.43 Premium 88 - 90 $2.73 Premium 91-94 $2.98 Sample Input and Output (output should match exactly, including decimal scale) Lee Gasoline Services 1. Discount 2. Premium Enter the brand type: 2 Enter the octane rating: 90 Enter the amount of gasoline in liters: 68.04 The cost of the gasoline is $49.07

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

Step: 3

blur-text-image

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

Define the elements, inputs, and outputs of an MRP system.

Answered: 1 week ago