Question

Compute for Miles Per Gallon in C++

Make a program that will calculate and compute for the quotient of miles and gallons (mpg: miles per gallons). Your program should must ask the user to specify the size of the array (using dynamic array) for the following variable: miles ,gallons and mpg. Prompt the user to Initialize  the value of miles (value for miles should be 100-250) and gallons (values should be from 5-25). Use pointer galPtr for gallons, milPtr for miles and mpgPtr for mpg.  Use function MilesPerrGallon (double,double) to compute for the values of mpg and use exception handling try-throw-catch  to validate the values of miles and gallons.  Finally set the width to 7 and the decimal places to 2.

#include
#include
using namespace std;
 
//global declaration
int i;
const int size=10;
typedef double *pointers;//typedefinition used for miles per gallon pointer variables
 
//prototype
//for grade elimination
void getInput(double *input);//prompt the user to input 10 grades
double getLow(double *low);//compute and returns the value of the lowest grade
double getSum(double *sum);//compute for the sum of 10 grades
//choices and try again
char getChoice(char *ch);//display the menu of choices and input the choice of the user
 
//miles per gallon
void MilesPerrGallon(double *ptr1,double *ptr2,int sz);//final output of the computer miles
//and gallons
void MperG();//prompts the user to specify the size of the array for miles and gallons
//verify and validate the input for miles and gallons using exception handling
 
 
int main()
{
            
            //add only declaration here 
do{
 
            chr=&choice;
            opt=getChoice(chr);
            
            switch(*chr)
            {
                        case '1':  
                                {
                                      double grade[size];
                                      double *ptr;
                                      double *plow, *psum, *pave;
                                      double gsum,glow;
                                      double ave;
                                      
                                      system("cls");
                                    //add declaration here
                                      
                                      system("cls");
                                    //add code here
 
//NOTE ALL CODES MUST USE pointer variables –input,process and //output
                                      
                                                }
                                    break;
                        case '2':  MperG();
                                    break;
                        case '3': 
                                    cout<<"goodbye for now....\n";
                                    system("pause");
                                    exit(1);
                                    break;
            }
            
            
               //Add code here
            cout<
                    
                
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Compute for Miles Per Gallon in C++
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Classwork 2-2: Input & Formatting A car's miles-per-gallon (MPG) can be calculated using the formula: MPG...

    Classwork 2-2: Input & Formatting A car's miles-per-gallon (MPG) can be calculated using the formula: MPG - miles driven/gallons of gas used Write a program that asks the user for the car's make, number of miles driven and the gallons of gas used. It should calculate the car's MPG and displays the result rounded to 2 decimal places. Example "Your Honda's MPG is 28.56" On Blackboard, submit a screenshot of successfully running and testing your code on HackerRank.com: www.hackerrank.com/csc124-chapter-2-classwork (2nd...

  • Drivers are concerned with the mileage their automobiles get. One driver has kept track of several...

    Drivers are concerned with the mileage their automobiles get. One driver has kept track of several tankfuls of gasoline by recording the miles driven and gallons used for each tankful. Develop a C# app that will input the miles driven and gallons used (both as integers) for each tankful. The app should calculate and display the miles per gallon obtained for each tankful and display the combined miles per gallon obtained for all tankfuls up to this point. All averaging...

  • Objective: Find out the “true” MPG (Miles Per Gallon) of a vehicle, given a group of...

    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 car’s 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...

  • A liter is 0.264179 gallons. Write a program that will read in the number of liters...

    A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user's car and the number of miles per gallon the car delivered. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of liters per gallon. After doing this... Modify your...

  • Write a program to compute miles per gallon of a car, over a long trip. The...

    Write a program to compute miles per gallon of a car, over a long trip. The car begins the trip with a full tank, and each fuel stop along the way fills the tank again. You will not do any math, arithmetic, or computations in the main() function. All output will be displayed from the main() function. Start the program by asking the user for the starting odometer reading. All odometer readings will be in whole miles only. The fuel...

  • You previously wrote a program that calculates and displays: Miles driven Miles per gallon Kilometers driven...

    You previously wrote a program that calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Messages commenting on a vehicle's fuel efficiency And also validates input Now we'll make a somewhat major change. We'll remove the code for obtaining input from a user and replace it with hardcoded data stored in lists. Because the data is hardcoded, the program will no longer need the code for validating input. So, you may remove...

  • // Enter your name as a comment for program identification // Program assignment TripCost.cpp // Enter...

    // Enter your name as a comment for program identification // Program assignment TripCost.cpp // Enter your class section, and time /* The program TripCost.cpp uses pointers to calculate    the cost of a trip depending on the cost of a gallon    of gas, the number of miles, and the number of miles    per gallon a car gets. */ /* The cost of gas, the number of miles, and number of    miles per gallon is entered. */...

  • CIS247C Week 3 Project Overview The objective of this week is to enhance last week's Vehicle cla...

    CIS247C Week 3 Project Overview The objective of this week is to enhance last week's Vehicle class by making the following changes: • Create a static variable called numVehicles that holds an int and initialize it to zero. This will allow us to count all the Vehicle objects created in the main class. • Add the copy constructor • Increment numVehicles in all of the constructors • Decrement numVehicle in destructor • Add overloaded versions of setYear and setMpg that...

  • //Add name, date, and description here //preprocessor directives #de fine CRT SECURE NO WARNINGS ...

    Complete the incomplete code provided //Add name, date, and description here //preprocessor directives #de fine CRT SECURE NO WARNINGS #includestdio.h> - //Calculate the cost of the gas on a trip /Ideclare, ask, and get the price per gallon and the mpg /Icalculate and return (by reference) the cost of gas for the number of miles passed to the function void GasCost (double miles, double *gasTotalPtr) //using a 70 MPH speed limit and the miles passed to the function //calculate and...

  • COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the...

    COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the algorithm for a AppStore programming assignment. The details of the assignment, a sample algorithm, and its outline, are located below. Make the algorithm at least half a page, easy to read, and to understand, how it works. I just want the algorithm, not the programming code, I have that. I only need the ALGORITHM. Thanks for helping me out, I apprieciate it, have a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT