Grizzly0132

highways

Sep 25th, 2021
659
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class test {
  4.     public static void main(String[] args) {
  5.         Scanner scnr = new Scanner(System.in);
  6.         int highwayNumber;
  7.         int primaryNumber;
  8.  
  9.         highwayNumber = scnr.nextInt();
  10.         // %100,
  11.         primaryNumber = highwayNumber % 100;
  12.         if ((highwayNumber < 1) || (highwayNumber > 999) || (highwayNumber % 100 == 0)) {
  13.             System.out.println(highwayNumber + " is not a valid interstate highway number.");
  14.         } else if (highwayNumber < 99 && highwayNumber > 1) {
  15.             if (highwayNumber % 2 == 0) {
  16.                 System.out.println("I-" + highwayNumber + " is primary, going east/west.");
  17.             } else{
  18.                 System.out.println("I-" + highwayNumber + " is primary, going north/south.");
  19.             }
  20.         }if (highwayNumber > 99 && highwayNumber < 999) {
  21.  
  22.             if (highwayNumber % 2 == 0) {
  23.                 System.out.println("I-" + highwayNumber + " is auxiliary, serving I-" + primaryNumber + ", going east/west.");
  24.             } else {
  25.                 System.out.println("I-" + highwayNumber + " is auxiliary, serving I-" + primaryNumber + ", going north/south.");
  26.             }
  27.         }
  28.  
  29.     }
  30. }
  31.  
RAW Paste Data