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
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