Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please I need help with this. I was already given a starting program, now I just need to complete it. I am writing in C++

Please I need help with this.

image text in transcribed

I was already given a starting program, now I just need to complete it. I am writing in C++ language.

Here is the given program:

#include

#include

const int CARBON_MONOXIDE = 1;

const int HYDROCARBON = 2;

const int NITROGEN_OXIDE = 3;

const int NONMETHANE_HYDROCARBON = 4;

const int QUIT = 0;

const double CARBON_MONOXIDE_ALLOWED1 = 3.4;

const double CARBON_MONOXIDE_ALLOWED2 = 4.2;

const double HYDROCARBON_ALLOWED1 = 0.31;

const double HYDROCARBON_ALLOWED2 = 0.39;

const double NITROGEN_OXIDE_ALLOWED1 = 0.4;

const double NITROGEN_OXIDE_ALLOWED2 = 0.5;

const double NONMETHANE_HYDROCARBON_ALLOWED1 = 0.25;

const double NONMETHANE_HYDROCARBON_ALLOWED2 = 0.31;

using namespace std;

void outputMenu();

int main(int argc, char *argv[])

{

int pollutant;

int odometer;

double gramsPerMile;

outputMenu();

cin >> pollutant;

while (pollutant != QUIT)

{

cout

cout

cin >> gramsPerMile;

cout

cin >> odometer;

switch (pollutant)

{

case CARBON_MONOXIDE:

break;

case HYDROCARBON:

break;

case NITROGEN_OXIDE:

break;

case NONMETHANE_HYDROCARBON:

break;

}

outputMenu();

cin >> pollutant;

}

cin.ignore();

cin.get();

}

void outputMenu()

{

cout

cout

cout

cout

cout

cout

cout

}

These are what the professor wants us to do:

1. Not change any of the given code.

2. Use the defined constant variables for any constant values in your program.

3. Create additional constant variables to use when checking the mileage boundaries (50000 miles and 100000 miles).

4. Output an indication that an invalid odometer reading has been entered (outside of the range of 0-100000).

5. Use the switch statement started in the program for your decision structure.

6. Have at least one other user defined function. One possibility is the following function that determines the allowable level for a particular pollutant:

double getAllowableLevel (double gramsPerMileAllowed1, double gramsPerMileAllowed2, int odometer);

Thank you so much in advance.

Specification Complete a program that has a user enter a pollutant choice, a number of grams of the pollutant emitted per mile, and an odometer reading (0-100000) Output an indication of whether or not they are compliant with the following regulations: first 50,000 miles second 50,000 miles carbon monoxide 3.4 grams/mile 4.2 grams/mile 0.31 grams/mile 0.39 grams/mile hydrocarbons 0.4 grams/mile 0.5 grams/mile nitrogen oxides non-methane hydrocarbons 0.25 grams/mile 0.31 grams/mile A sample run is shown here: (1 Carbon monoxide (2 Hydrocarbons X3 Nitrogen oxides (4 Non-nethane hydrocarbons CO> Quit Enter choice: 1 Enter grans en itted per mile: 3.2 Enter odometer reading 77000 Enissions within allowable level of 4.2 grans nile X1 Carbon monoxide (2 Hydrocarbons X3 Nitrogen oxides C4> Non methane hydrocarbons CO> Quit Enter choice: 2 Enter grans enitted per mile .25 Enter odometer reading 23456 sions within allowable level of 0.31 grams nile X1 arbon monoxide Hydrocarbons X3 oxides K4> Non-nethane hydrocarbons CO> Quit Enter choice: 3 Enter grans enitted per mile Enter odometer reading 100100 Mileage 100100 must be within 0-100000 miles (1 arbon monoxide X2 Hydrocarbons C3> Nitrogen oxides K4> Non-methane hydrocarbons Quit Enter choice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago