Question: 2.10 LAB: Branches: Interstate highway numbers Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like

2.10 LAB: Branches: Interstate highway numbers

Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, the 405 services the 5, and the 290 services the 90.

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.

Ex: If the input is:

90 

the output is:

The 90 is primary, going east/west. 

Ex: If the input is:

290 

the output is:

The 290 is auxiliary, serving the 90, going east/west. 

Ex: If the input is:

0 

or any number not between 1 and 999, the output is:

0 is not a valid interstate highway number.

++++ANSWER++++

integer highwayNumber integer primaryNumber

highwayNumber = Get next input primaryNumber = highwayNumber%100

if highwayNumber >= 1 and highwayNumber <= 99 if highwayNumber%2==0 Put "The" to output Put " " to output Put highwayNumber to output Put " " to output Put "is primary, going east/west." to output else Put "The " to output Put highwayNumber to output Put " is primary, going north/south." to output

elseif highwayNumber >= 100 and highwayNumber <= 999 if highwayNumber%2==0 Put "The" to output Put " " to output Put highwayNumber to output Put " " to output Put "is auxiliary, serving the" to output Put " " to output Put primaryNumber to output Put ", going east/west." to output else Put "The" to output Put " " to output Put highwayNumber to output Put " " to output Put "is auxiliary, serving the" to output Put " " to output Put primaryNumber to output Put ", going north/south." to output

elseif highwayNumber == 0 Put "0 is not a valid interstate highway number." to output

elseif highwayNumber == 1000 Put "1000 is not a valid interstate highway number." to output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!