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, 22.06.2019 11:30
Hassan is writing his master’s thesis, which is a thirty-page document. he received some feedback from his professor in the form of comments, but does not see where the comments are. what is the fastest way for hassan to find the feedback?
Answers: 3
question
Computers and Technology, 22.06.2019 12:30
An atom's diameter is about 0.1 nanometer (1×10-9m), and a human hair is about 1×10-3m. how many times greater is a human hair than an atom's diameter? sorry pushed wronf button but this is math
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
The two main ways in which marketers address the competition with their strategies are by satisfying a need better than a competition and by
Answers: 2
question
Computers and Technology, 23.06.2019 00:10
Write a function so that the main0 code below can be replaced by the simpler code that calls function mphandminutes tomiles0. original main0 int main) l double milesperhour-70.0; double minutestraveled = 100.0; double hourstraveled; double milestraveled; hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; cout < "miles" 2 using namespace std; 4 /* your solution goes here/ 6 int maino 1 test passed 7 double milesperhour 70.0 all tests passed 8 double minutestraveled 100.0; 10 cout < < "miles: " < < mphandminutestomiles(milesper-hour, minutestraveled) < < endl; 12 return 0; 13
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
Mathematics, 15.12.2019 06:31
question
World Languages, 15.12.2019 06:31
question
Computers and Technology, 15.12.2019 06:31
question
Mathematics, 15.12.2019 06:31
Questions on the website: 13722367