subject

I need this answered in JAVA: 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, I-405 services I-5, and I-290 services I-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:

I-90 is primary, going east/west.
Ex: If the input is:

290
the output is:

I-290 is auxiliary, serving I-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.
Ex: If the input is:

200
the output is:

200 is not a valid interstate highway number.

This is what I've got so far- but I'm not really understanding fully...

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)) {
if (highwayNumber <= 99) {
if (highwayNumber %2 == 0) { //recognizes even numbers
System. out. printf("I-%d is primary, going east/west.\n", highwayNumber);
}
else {
System. out. printf("I-%d is primary, going north/south.\n", highwayNumber); //recognizes other than even numbers
}
}
else {

primaryNumber = highwayNumber;

highwayNumber %= 100; //what does this mean?

if (highwayNumber % 2 == 0) { //recognizes even numbers
System. out. printf("I-%d is auxiliary, serving the I-%d, going east/west.\n", primaryNumber, highwayNumber);

}
else {

System. out. printf("I-%d is auxiliary, serving the I-%d, going north/south.\n", primaryNumber, highwayNumber);
}
}

} else {

System. out. printf("%d is not a valid interstate highway number.\n", highwayNumber);

}

}
}
This answer is incomplete, because when I input 200, the out put is:
I-200 is auxiliary, serving the I-0, going east/west.

it should be:
200 is not a valid interstate highway number.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. andre was recently hired by an organization to check for system vulnerabilities. he is supposed to exploit these vulnerabilities and create a report on the extent of damage to which the system was susceptible. what position does andre hold in this organization? a. information security analyst b. information assurance manager c. penetration tester d. network security engineer e. chief information security officer
Answers: 2
question
Computers and Technology, 24.06.2019 11:30
What does the https: // mean when you type in a website
Answers: 1
question
Computers and Technology, 24.06.2019 19:50
Which is a characteristic of free and open-source software licenses? a. the source code is unavailable to everyone b. the source code is available only to the government c. the source code is available to all users d. the source code is constantly modified
Answers: 1
question
Computers and Technology, 25.06.2019 00:30
You are to write a series of steps that anyone could follow to solve the following three problems: 1. even odd a. assume that someone tells you a number (an integer number) b. you hear the number and respond with the word even or odd 2. average a. assume that someone tells you between 3 and 5 numeric values. b. you hear the numbers and respond with the average is some number 3. dog or cat a. explain to a child the differences between a dog and a cat. b. your explanation could be used by a child or anyone to distinguish the difference between a dog and a cat
Answers: 1
You know the right answer?
I need this answered in JAVA: Primary U. S. interstate highways are numbered 1-99. Odd numbers (lik...
Questions
question
Health, 11.12.2020 03:30
question
Arts, 11.12.2020 03:30
question
Chemistry, 11.12.2020 03:30
question
Mathematics, 11.12.2020 03:30
question
Biology, 11.12.2020 03:30
question
Mathematics, 11.12.2020 03:30
question
Mathematics, 11.12.2020 03:30
Questions on the website: 13722366