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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, allierl2001
Felicia wants to become a head surgeon by december 2013. she designs the career milestones that she would need to complete her goal. by june 2013, she was not licensed. which best describes what she should do?
Answers: 2
image
Computers and Technology, 24.06.2019 02:10, trint5952
Aspeed limit sign that says "night" indicates the legal speed between sunset and sunrise.
Answers: 2
image
Computers and Technology, 24.06.2019 15:20, 710jonathan
Local area networks use many of the same network technologies and the internet, only on a smaller scale. devices that access lans are equipped with a network interface that contains circuitry for wireless or wired connections. devices also have a physical address, in addition to the ip addresses acquired from a dhcp server. the most popular wired technology is . the most popular wireless technology is , which can be configured as a(n) or star topology. setting up a lan and configuring its router is fairly easy. the first step is to change the standard to one that is secure. next, create a(n) that uniquely identifies the network by name. it is also important to activate wireless to prevent wireless signals from being intercepted during transmission. a limited-access network can be created for visitors to use. by activating , the router will be able to assign ip addresses to each device that joins the network. to connect to a secure lan that is protected by encryption, an encryption , or password, is required. lans can be used to access data collected by iot devices and the networks that tie these devices together. technologies such as rfid, nfc, bluetooth smart, zigbee, and z-wave offer -power links, essential for battery-powered devices that can’t expend excess amounts of energy transmitting data.
Answers: 1
image
Computers and Technology, 24.06.2019 17:30, leenzazou98241
What is the next step if your volume does not work on computer
Answers: 2
You know the right answer?
I need this answered in JAVA: Primary U. S. interstate highways are numbered 1-99. Odd numbers (lik...

Questions in other subjects:

Konu
Mathematics, 25.01.2021 14:00
Konu
Mathematics, 25.01.2021 14:00