Answer to Question #122040 in C++ for JULIET

Question #122040
Write a complete c++ program to display the status and the message of the API(AIR POLLUTION INDEX) . Define the status as a string type. Use following function header:
int getInput() : to receive input for the API
string API_CATEGORY (int api) : to determine the API status and the message and return the status to main() to be output.
1
Expert's answer
2020-06-15T15:03:05-0400
#include <iostream>
using namespace std;


int getInput()
{
    cout << "Enter Air Pollution Index: ";
    int api;
    cin >> api;
    return api;
}


string API_CATEGORY (int api)
{
    if (api >=0 && api <=50)
        return "Good";
    if (api >=51 && api <=100)
        return "Moderate";
    if (api >=101 && api <=200)
        return "Unhealthy";
    if (api >=201 && api <=300)
        return "Very unhealthy";
    if (api >=301 && api <=500)
        return "Hazardous";
    return "Emergency";
}


int main()
{
    int api = getInput();
    cout << "API status: " << API_CATEGORY(api);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS