Question: C++ Programming This program will ask the user to enter the miles driven and gallons of gas used to calculate a cars gas mileage or

C++ Programming

This program will ask the user to enter the miles driven and gallons of gas used to calculate a cars gas mileage or miles-per-gallon (MPG), which can be calculated with the following formula: MPG = Miles Driven / Gallons of gas used For this assignment you will create a program that has a class called Mileage. The Mileage class should have two private member variables called miles and gallons of the primitive data type double. The class should have four public methods: setMiles and setGallons should use the void return types; getMiles and getGallons should use double return types. It should have one more method called getMPG that performs the math calculation and returns the double MPG. You will create a main program called MPGMain that asks the user for the number of miles driven and the gallons of gas used. It should create an instance of the Mileage class to calculate the cars MPG. The class should return the MPG to the MPGMain where it was called and display the value on the console. Be sure to limit the display to two decimal places.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!