QUESTION
IN JAVA PLEASE. In this project we are going to create a class Sedan. A sedan is a four wheeled automobile with 4 doors. Each sedan can have a different gas tank that has a fixed capacity, and it can contain certain number of gallons of fuel. We will assume that each sedan can get a different fixed constant miles per gallon, and there is an EPA standard miles per gallon for all sedans that gets updates every year. The sedan also has a mileage. Right out of the factory, the sedan has a full tank of gas and zero mileage.
CLASS Sedan:
public Sedan(double ptankCapacity, double mpg)
public String toString()
public double drive(double miles)
public double pumpFuel(double gallons)
public double pumpFuel()
public static boolean setEPA(double newEPAmpg)
CLASS SedanTest:
static double readNNegDouble(String s)
Sample Output:
Sedan 1
Sedan 1 created.
Sedan with 4 wheels and 4 doors,
with 10.0 gallon fuel tank and 10.0 gallons fuel,
with 0.0 mileage,
and with 25.0 mpg meeting the EPA mpg of 25.0.
Sedan 2
Enter tank capacity:
-1
ERROR - input a non-negative number
Enter tank capacity:
10
Enter MPG:
-5
ERROR - input a non-negative number
Enter MPG:
25
Sedan with 4 wheels and 4 doors,
with 10.0 gallon fuel tank and 10.0 gallons fuel,
with 0.0 mileage,
and with 25.0 mpg meeting the EPA mpg of 25.0.
Sedan 2 created.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
d
Enter miles:
100
100.0 actual miles driven.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
p
Enter gallons:
50
4.0 actual gallons pumped.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
d
Enter miles:
1000
250.0 actual miles driven.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
u
10.0 actual gallons pumped.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
d
Enter miles:
200
200.0 actual miles driven.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
s
Sedan with 4 wheels and 4 doors,
with 10.0 gallon fuel tank and 2.0 gallons fuel,
with 550.0 mileage,
and with 25.0 mpg meeting the EPA mpg of 25.0.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
e
Enter EPA mpg:
30
EPA mpg updated.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
s
Sedan with 4 wheels and 4 doors,
with 10.0 gallon fuel tank and 2.0 gallons fuel,
with 550.0 mileage,
and with 25.0 mpg not meeting the EPA mpg of 30.0.
-------------
Menu
-------------
(D)rive
(P)ump fuel
Pump (U)p
Change (E)PA
Sedan (S)tats
(Q)uit
-------------
q
Program Terminated.