Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I cannot figure out what this wants? Works fine in other comiler but not in ZyBo

ID: 3879362 • Letter: I

Question

I cannot figure out what this wants? Works fine in other comiler but not in ZyBooks... using JAVA.

Challenge Activity 3.3.3: Multiple branch If-else statement: Print century Write an if-else statement with multiple branches. If givenYear is 2100 or greater, print "Distant future" (without quotes). Else, if givenYear is 2000 or greater (2000-2099), print "21st century". Else, if given Year is 1900 or greater (1900-1999), print "20th century" Else (1899 or earlier), print "Long ago". Do NOT end with newline 1 import java.util.scanner; 3 public class YearChecker [ 4public static void main (String [] args) int givenYear = 0; givenYear = 1776 ; if (givenYear >= 2100) { 6 7 10 System.out.println("Distant future"); else if (givenYear >= 2000) 12 13 14 15 16 17 18 19 20 System.out.println("21st century"); else if (givenYear >= 1900) { System.out.println("20th century"); else System.out.println("Long ago"); Run X Testing with givenYear 1776 Whitespace differs; see green (missing whitespace) or red (extra whitespace) boxes below Expected output: Long ago Long ago Your output: Tests aborted

Explanation / Answer

use System.out.print("Long ago")

You have used System.out.println("Long ago") which is printing one new line character also.

That is making your output not to be in sync with the expected output.

Modify all 4 System.out.println() statements to to System.out.print()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote