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 G here to search The 290 is auxiliary, serving the 90, going eas 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. See Wikipedia for more info on highway numbering LAB 4.16.1: LAB: Interstate highway numbers ACTIVITY LabProgr- 1 import java.util.Scanner; 2 3 public class LabProgram public static void main(Stringl] args) t Scanner scnr new Scanner(System.in); int highwayNumber; int primaryNumber; 4 5 6 7 highwayNumber scnr.nextInt(); 1e Type your code

Respuesta :

Answer:

The Java code is given below with appropriate variable names and tags for better understanding

Explanation:

import java.util.Scanner;

public class LabProgram{

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       int highwayNumber;

       int primaryNumber;

       highwayNumber = scnr.nextInt();

       if(highwayNumber<1 || highwayNumber>999)

           System.out.println(highwayNumber+" is not a valid interstate highway number.");

       else{

           if(highwayNumber>=1 && highwayNumber<=99){

               System.out.print("The "+highwayNumber+" is primary, going ");

               if(highwayNumber%2==1)

                   System.out.println("north/south.");

               else

                   System.out.println("east/west.");

           }

           else{

               primaryNumber = highwayNumber%100;

               System.out.print("The "+highwayNumber+" is auxillary, serving the "+primaryNumber+", going ");

               if(primaryNumber%2==1)

                   System.out.println("north/south.");

               else

                   System.out.println("east/west.");

           }

       }

   }

}

The program is an illustration of conditional statements.

Conditional statements are statements whose execution is dependent on its truth value.

The missing code segment in Java where comments are used to explain each line is as follows:

import java.util.Scanner;

public class Main {

   public static void main(String [] args){  

       Scanner scnr = new Scanner(System.in);  

       int highwayNumber; int primaryNumber;

       highwayNumber = scnr.nextInt();

       //This checks if the highwayNumber is not between 1 and 999 (inclusive)

       if (highwayNumber <1 || highwayNumber > 999){

           //If yes, the highwayNumber is invalid

           System.out.print(highwayNumber+" is not a valid interstate highwayNumber number.");

       }

       //If otherwise

       else{

           //This checks if highwayNumber is less than 100

           if (highwayNumber< 100){

               if (highwayNumber%2 == 0){

                   //Even highwayNumber are primary going east/west

                   System.out.print("I-"+highwayNumber+" is primary, going east/west.");

               }

           else{

               //Odd highwayNumber are primary going north/south

               System.out.print("I-"+highwayNumber+" is primary, going north/south.");

           }

           }

           //Otherwise

           else{

               if ((highwayNumber%100) % 2 == 0){

                   //Even highwayNumber are auxiliary going east/west

                   System.out.print("I-"+highwayNumber+" is auxiliary, going east/west.");

               }

               else{

                   //Even highwayNumber are auxiliary going north/south

                   System.out.print("I-"+highwayNumber+" is auxiliary, going north/south.");

               }

           }

       }

   }

}

Read more about similar programs at:

https://brainly.com/question/22078310

ACCESS MORE