CodeGym /Courses /New Java Syntax /Tasks about loops

Tasks about loops

New Java Syntax
Level 4 , Lesson 4
Available

"Hi, Amigo!"

"I heard that you've learned about loops. I'll give you a couple of tasks."

4
Task
New Java Syntax, level 4, lesson 4
Locked
10 numbers
Display the numbers from 1 to 10 using a while loop. Each value should be on a new line.
4
Task
New Java Syntax, level 4, lesson 4
Locked
From 10 to 1
Display the numbers from 10 to 1 using a while loop. Each value should be on a new line.
4
Task
New Java Syntax, level 4, lesson 4
Locked
You can't have too much of a good thing
Use the keyboard to enter a string and a number N greater than 0. Use a while loop to display the string N times. Each value should be on a new line. Example input: abc 2 Example output: abc abc
4
Task
New Java Syntax, level 4, lesson 4
Locked
Seeing dollars in your future
Use a while loop to display a 10x10 square of dollar signs. Don't separate the symbols in each line. Example output: $$$$$$ $$$$$ $$$$$ $$$$$ $$$$$ $$$$$ $$$$$ $$$$$ $$$$$ $$$$$
Comments (40)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Anonymous #10782038 Level 24, United States of America
14 December 2023
None of these require nested while loops, not sure why i see so many people talking about them..
Naif Al-Jaaidi Level 9, Aden, Yemen
28 November 2023
I did loop in loop with three variables two integers and one string because it's more challenging. Hint: The three variables are not in the same block. Good luck!
Krzysztof Kosała Level 21, Wejherowo, Poland
23 July 2023
In the last task don't do something like this: String = "$$$$$$$$$$"; because it's very stupid. Of course you can but what if you need this matrix in size 20x20, or 100x100 ? Try loop in loop. And remember: System.out.println(); // that is: subsequent outputs will be printed on the next line System.out.print(); // print in THIS line Good luck!
12 May 2023
For the last one, I used a while loop and did NOT use any multiplication to get the correct answer. I practically used the code for the "10 to 1" practice example. I added a string variable ex. String text = "$$$$$$$$$$"; and I used x--; to countdown from 10 leaving me with the correct answer. hopes this helps anyone who doesn't want to do multiplication.
Anonymous #11263139 Level 7, Mexico
21 February 2023
Hint : You can check the Multiplication table task in level 3 lesson 6, and adapt to loop while
Ali_Alshehri Level 6, Saudi Arabia
19 May 2022
hahaha I try to enter the signed dollar from user my new lesson here is to read all requirements
Anonymous #10948087 Level 6, Spain
7 March 2022
Pienso que las tareas no son proporcionadas en dificultad a los contenidos que se ven en cada apartado. Por ejemplo, en el caso de los bucles, apenas se enseña la mecánica de un bucle while y ya te están poniendo tareas que requieren bucles while anidados, cuando uno no tiene por qué conocerlos de antemano. Esto sucede en cada sección, donde se mezclan tareas extremadamente simples con otras innecesariamente complicadas y que requieren aplicar técnicas que no se han visto.
Mindre Mercedes Bautista Level 6, Rome, Italy
2 March 2022
tenemos que crear dos ciclos while para multiplicar i * j
scriptKing Level 7, Australia
25 August 2021
Honestly you should have seen how boss my nested while loop was for this my mind explodes at the posibilities.
KARMA GURUNG Level 5, Wyken, United Kingdom
17 February 2021
hint : nested for loop just like previous $ solution.