Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.
#include <iostream>
using namespace std;
int main()
{
cout<<"Enter high number: \n";
int high;
int primary;
cin>>high;
if(high>0 && high<=99) {
if(high %2!=0) {
cout<<"I-"<< high << " is primary, going north/south"<<endl;
}
else {
cout<<"I-"<<high << " is primary, going east/west"<<endl;
}
}
else if(high>=100 && high<=999) {
primary=high;
if(high%2!=0) {
cout<<"I-"<< high << " is auxillary," <<" serving I- "<<high%100 <<" going north/south\n";
}
else {
cout<<"I-"<< high << " is auxillary," <<" serving I- "<< (primary%100)<<" going east/west\n";
}
}
else {
cout<<high<< " is not a valid interstate highway number\n";
}
return 0;
}
Comments
Leave a comment