
Concept explainers
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.
This is the code I have but for some reason I keep getting errors. what am doing wrong?
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); {
System.out.println(highwayNumber + " is a primary highway, going east/west");
} else {
System.out.println(highwayNumber + " is a primary highway, going north/south");
}
else {
primaryNumber = highwayNumber;
highwayNumber %= 100;
System.out.println(pimaryNumber + " is an auxiliary highway, serving primary highway " + highwayNumber);
}
} else {
System.out.println(primaryNumber + " is not a valid interstate highway number.");
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Let S(x) = "x is a student in our class” and P(x) = "x lives in Wahiawa" a. Assume the u.d. for x is students in our class. Translate into symbols, "There is a student in our class who lives in Wahiawa. b. Assume the u.d. for x is all people. Translate into symbols, "There is a student in our class who lives in Wahiawa.arrow_forwardA year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 - leap year Ex: If the input is: 1913 the output is: 1913 - not a leap yeararrow_forward7. The roots of the quadratic equation ax² + bx + c = 0, a 0 are given by the following formula: -b = √b² - 4ac 2a In this formula, the term b² - 4ac is called the discriminant. If b²-4ac0, then the equation has a single (repeated) root. If 200arrow_forward
- Write T if the sentence is right; write F else, and fix the incorrect one. You need only respond to 5 of the following questions.The get() function may be used to append a new plot to an existing one.arrow_forwardGiven two integers, a and b, return true if a can be divided evenly by b. Return false otherwise. Examples divides Evenly (98, 7) true // 98/7 = 14 → divides Evenly (85, 4) false // 85/4 = 21.25 → Notes a will always be greater than or equal to b.arrow_forwardA year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 is a leap year. Ex: If the input is: 1913 the output is: 1913 is not a leap year. Your program must define and call the following function. The function should return True if the input year is a leap year or False otherwise.def is_leap_year(user_year)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





