Question
Objective: Find out the true MPG (Miles Per Gallon) of a vehicle, given a group of conditions which the user provides values for. 5 are
Objective: Find out the true MPG (Miles Per Gallon) of a vehicle, given a group of conditions which the user provides values for. 5 are given, 1 you create on your own. Requirements:
Prompt the user for the cars MPG first. i.e. Please Enter MPG: 26
Then prompt the user to enter a value for six factors which will affect the MPG of the vehicle, prompting for single value inputs after showing menus (i.e. a series of println() statements showing the options/valid values to enter)
After collecting all of the inputs, provide a detailed report of the inputs, their meaning, how much they affect MPG, as well as the the beginning and final MPG.
The following criteria will be used for the six inputs.
City or Highway Driving: Use a boolean type variable for input
City Subtracts 2 from MPG
Highway Adds 5 to MPG
Rainy or Sunny: Use a String type variable for input
Rainy Subtracts 1 from MPG
Sunny No Change to MPG
Elevation: Use a char type variable for input
S for Steep, Steep Subtracts from 5MPG
H for Hilly, Hilly Subtracts 3 from MPG
F for Flat, No Change to MPG
Weight in Vehicle (cargo or passenger): Use double type for input
Each 100lbs subtracts 0.5 MPG
Speed Preference: Use an int type variable for input
1 for under speed limit, Add 2 to MPG
2 for at speed limit, No Change to MPG
3 for 5% above speed limit, Subtract 1 from MPG
4 for 10% above speed limit, Subtract 3 from MPG
5 for over 20% above speed limit, Subtract 5 from MPG
Suggestion: Use a switch() statement for Speed Preference
Add one additional factor which you will prompt the user for, that affects MPG such as
tire pressure/condition,
hybrid vs. gas powered,
engine condition,
towing load,
2WD/4WD,
etc.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started