Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java loop using input user

import java.util.Scanner;

public class loop {
    public static void main(String[] args) {
        System.out.println("How much do you wanna make loop: "); // asking how many times u wanna loop
        try (Scanner sc = new Scanner(System.in)) {
            int x    = sc.nextInt();
            for (int i = 1; i < x; i++) {   // this code make ur loop starts with 1 and end by ur answer -1.
                System.out.println("loop "+i+" times"); // this will print out ur result
            }
            
            }
        }
    }
 
 
PREVIOUS NEXT
Tagged: #java #loop #input #user
ADD COMMENT
Topic
Name
5+2 =