Answer to Question #249563 in C++ for josh

Question #249563

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.


1
Expert's answer
2021-10-11T00:05:25-0400
#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;
}

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