+ 1

How to make the "Enter the number" continue again and again?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner in= new Scanner(System.in); System.out.print("Enter a number: "); int num = in.nextInt(); while(num >= 0){ System.out.print(num); num--; } } }

7th Dec 2019, 3:20 PM
strykds
strykds - avatar
15 Answers
+ 4
If you are asking about Sololearn Playground then it's not possible here. You have to run each time to take input.
7th Dec 2019, 3:24 PM
A͢J
A͢J - avatar
+ 4
put the entire thing in a loop. infinite loop is impossible though in SL playground.
7th Dec 2019, 3:31 PM
Taste
Taste - avatar
+ 1
you know how to write loop right ? i see it in the code you're presenting. its same as that but its cover most of the code
7th Dec 2019, 4:21 PM
Taste
Taste - avatar
+ 1
That's what I would want from the platform. The data input and output could be made interactive.
8th Dec 2019, 11:03 AM
JaScript
JaScript - avatar
0
Taste how to make the entire thing loop though?
7th Dec 2019, 4:19 PM
strykds
strykds - avatar
0
strykds can you just write how you want the output to be.
7th Dec 2019, 4:57 PM
Avinesh
Avinesh - avatar
0
Avinesh Enter a number: 5 5 4 3 2 1 0 Enter a number: 4 4 3 2 1 0 Enter a number: 2 2 1 0 And so on...
7th Dec 2019, 7:55 PM
strykds
strykds - avatar
0
See if this is what you are looking for. But you asked the same question in your last post as well. https://code.sololearn.com/c0pIzA8RJe36/?ref=app
7th Dec 2019, 7:56 PM
Avinesh
Avinesh - avatar
0
Avinesh after it showed up "enter a number" though, it already said process finished
7th Dec 2019, 7:59 PM
strykds
strykds - avatar
0
The way you showed your output, this is how you do it. Do you want to enter the numbers again and again? If so, till when?
7th Dec 2019, 8:01 PM
Avinesh
Avinesh - avatar
0
while(true ){ //code }
8th Dec 2019, 4:47 AM
Wei Phyo Aung
Wei Phyo Aung - avatar
0
look up how to make a loop. should hopefully help
9th Dec 2019, 3:41 AM
ageekwithglasses
ageekwithglasses - avatar
0
Loop
9th Dec 2019, 3:05 PM
PRIYANSHU RANJAN
PRIYANSHU RANJAN - avatar
0
Iteration in JAVA
9th Dec 2019, 3:05 PM
PRIYANSHU RANJAN
PRIYANSHU RANJAN - avatar
0
It is possible, check out this code https://code.sololearn.com/chKSj9L2ekLA/?ref=app
9th Dec 2019, 3:13 PM
Juraj Siman
Juraj Siman - avatar