Question: C# using Visual Studio You are planning to buy a vehicle and need an app to compare the time, fuel consumption, and cost for a
C# using Visual Studio
You are planning to buy a vehicle and need an app to compare the time, fuel consumption, and cost for a mile commute. The app uses the following class hierarchy to represent your vehicular options: Bicycle, Auto, or PHEV plugin hybrid
All options have a name Name an average speed Speed in miles per hour, the number of miles travelled Miles and the required time in hours Hours Hours is always MilesSpeed
The auto option Auto uses fuel Gallons with an average fuel consumption MPG and fuel cost Cost Assuming a fuel price of $ per gallon, the fuel cost is: Gallons $ The gallons of fuel consumed Gallons is Miles MPG The Auto constructor has three parameters: Name, Miles and MPG Assume your average speed by auto is mph
A PHEV is a plugin hybrid auto that switches to gas when battery power runs out. Gallons of fuel is determined by first subtracting the battery range Range from the miles driven: Miles Range Mpg The PHEV constructor has an additional parameter for the battery range.
The bicycle option is more economical but slower. Assume a cyclist bikes an average speed of divided by their weight Weight so speed is: Weight A bicycle doesnt have Cost because it is not an auto and uses no fuel. The Bicycle constructor has three parameters: Name, Miles, and Weight.
No methods are needed for this hierarchy.
Now, create a collection of vehicles that includes a bicycle, an auto, and a PHEV, for a mile commute. The cyclist weights lbs The auto a Cadillac gets mpg The PHEV a Chevy Volt gets mpg with a range of miles. Use a single loop to display the Hours, Gallons, and Cost of each vehicular option. If the vehicle is not an auto, omit Gallons and Cost from the output, as shown. You are planning to buy a vehicle and need an app to compare the time, fuel consumption, and cost for a mile commute. The app uses the following class hierarchy to represent your vehicular options: Bicycle, Auto, or PHEV plugin hybrid
Vehicle Hierarchy
All options have a name Name an average speed Speed in miles per hour, the number of miles travelled Miles and the required time in hours Hours Hours is always MilesSpeed
The auto option Auto uses fuel Gallons with an average fuel consumption MPG and fuel cost Cost Assuming a fuel price of $ per gallon, the fuel cost is: Gallons $ The gallons of fuel consumed Gallons is Miles MPG The Auto constructor has three parameters: Name, Miles and MPG Assume your average speed by auto is mph
A PHEV is a plugin hybrid auto that switches to gas when battery power runs out. Gallons of fuel is determined by first subtracting the battery range Range from the miles driven: Miles Range Mpg The PHEV constructor has an additional parameter for the battery range.
The bicycle option is more economical but slower. Assume a cyclist bikes an average speed of divided by their weight Weight so speed is: Weight. A bicycle doesn't have Cost because it is not an auto and uses no fuel. The Bicycle constructor has three parameters: Name, Miles, and Weight.
No methods are needed for this hierarchy.
Now, create a collection of vehicles that includes a bicycle, an auto, and a PHEV, for a mile commute. The cyclist weights lbs The auto a Cadillac gets mpg The PHEV a Chevy Volt gets mpg with a range of miles. Use a single loop to display the Hours, Gallons, and Cost of each vehicular option. If the vehicle is not an auto, omit Gallons and Cost from the output, as shown.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
