In: Computer Science
The program should be written in C++ with comments
Write a program that takes graduation rates (per 1000 of the population) for North, South, East, West and Central United States. Input the number from each of the regions in a function returning an int with the graduation rate to the main program. Also figure out which region has the highest graduation rate in another function and display the result from inside that particular function.
So your function prototypes should be something like:
int gradrate( );
void highestgrad(double n, double south, double east, double west,
double central);
So you are using gradrate to read in the value of 0 to 1000 to give it to the north, south, east, west or central variables like: north = gradrate() / 1000.0;
Answer:
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <iostream>
using namespace std;
int graduate()
{
int num;
cin>>num;
if(num<0||num>1000)
{
cout<<"Invalid! please enter between 0 and 1000: ";
return graduate();
}
return num;
}
void highestgrad(double north,double south,double east,double
west,double central)
{
if(north>=south&&north>=east&&north>=west&&north>=central)
{
cout<<"North has highest grad with value
"<<north<<endl;
}
else
if(south>=north&&south>=east&&south>=west&&south>=central)
{
cout<<"south has highest grad with value
"<<south<<endl;
}
else
if(east>=south&&east>=north&&east>=west&&east>=central)
{
cout<<"east has highest grad with value
"<<east<<endl;
}
else
if(west>=south&&west>=east&&west>=north&&west>=central)
{
cout<<"west has highest grad with value
"<<west<<endl;
}
else
if(central>=south&¢ral>=east&¢ral>=west&¢ral>=north)
{
cout<<"central has highest grad with value
"<<central<<endl;
}
}
int main()
{
cout<<"Enter for north from 0 to 1000: ";
double north,south,east,west,central;
north=(double)graduate()/1000.0;
cout<<"Enter for south from 0 to 1000: ";
south=(double)graduate()/1000.0;
cout<<"Enter for east from 0 to 1000: ";
east=(double)graduate()/1000.0;
cout<<"Enter for west from 0 to 1000: ";
west=(double)graduate()/1000.0;
cout<<"Enter for central from 0 to 1000: ";
central=(double)graduate()/1000.0;
highestgrad(north,south,east,west,central);
return 0;
}
output: