Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java GUI format (not an applet) Objective: Write a Java program that will calculate the miles-per-gallon achieved during a trip, given the beginning and

In Java GUI format (not an applet)

Objective: Write a Java program that will calculate the miles-per-gallon achieved during a trip, given the beginning and ending odometer readings and the gallons of gasoline used. In addition, the program will calculate the number of miles that can be traveled on the remaining gallons of gasoline in the tank.

Use good comments:

Think about the problem and decide what type each of the input numbers should be. Also, think about the calculations and decide what type the variables should be that will hold the results of the calculations.

Use camel casing for variable names, and use descriptive variable names. Do not use general variable names like "tax" or "total."

Create text fields for the beginning and ending odometer readings.

Test to see that the ending odometer reading is larger than the beginning odometer reading. *

Assume that the gasoline tank holds 20 gallons. Assume that you start the trip with a full tank of gasoline. Also assume that at the end of the trip that you fill up the tank and record the number of gallons used.

Create a Calculate button to be used once the odometer readings have been entered.

Create a text field for the number of gallons used during the trip.

Calculate and display the number of miles driven and display the result in an uneditable text field.

Calculate the MPG for the trip and display the results in an uneditable field.

Calculate the number of miles that can still be traveled (based on the MPG for the trip) on the fuel still in the tank, and display the results.

Use an inner class for the listener.

2.2. GUI Format

Make the layout logical and intuitive for the user.

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions