CodeGym /Courses /Java Syntax /Tasks with and without asterisks

Tasks with and without asterisks

Java Syntax
Level 4, Lesson 16
Available

"Hello, soldier!"

"Hello, Captain Squirrels, sir!"

"I have great news for you. Here are some exercises to reinforce your skills. Work on them every day, and your competence will grow exponentially. They were specially designed for IntelliJ IDEA."

Comments (60)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Anonymous #11655448 Level 14, New York City, United States
21 March 2026
while (true) { // int number = read the number; if (firstnum == -1 || secondnum == -1 || thirdnum == -1 || fourthnum == -1 || fifthnum == -1) { System.out.println(firstnum + secondnum + thirdnum + fourthnum + fifthnum); } break; } I don't understand....The program is telling me to include -1 in the sum, but -1 was added in the sum. This was the input data: -1 11 19 9 14
Anonymous #11655448 Level 14, New York City, United States
21 March 2026
"I will never work for peanuts. Amigo" is a weird line to print, but okay.
NebraskaBigFoot Level 5, United States
23 May 2025
"They were specially designed for IntelliJ IDEA" but we don't install IntelliJ IDEA until level 5 lesson 3?
nealgoogs Level 21, Eliot, United States
19 August 2024
you can use break in the last question.
Donkasking Level 6, United States
7 August 2024
That last one was a doozy! For future challengers, the placement of where you parse your integers matters!
Chris Christi Level 6
6 June 2024
8 attempts?!! OMG, am I too thick to be a Java developer?!!!
Anonymous #11655448 Level 14, New York City, United States
21 March 2026
nope it just means ya need more practice
tri bui Level 7, Saigon, Viet Nam
28 May 2024
lesson learn: "read you test carefully!"
Luke Level 5, Saint Paul, United States
19 February 2024
Codegym you think you're sooooo smart making us include -1 in the summation ;)
Rather Be Coding Level 14, Detroit, United States
26 August 2023
So, you want to add -1 as well? Strange if we're breaking when that is entered.
Reganralph Level 6, DORTMUND, Germany
15 June 2022
int b = 0; while (true){ int a = Integer.parseInt(bb.readLine()); if (a<=-1){ b = b+a; System.out.println(b); break; } b=b+a; } please cna i get help as to why this SAYS Be sure that the program works correctly with negative numbers.
rags 3 Level 5, Wichita, United States Expert
5 July 2023
you need your if statement farther down i think below b+a