0

find the error

import java.util.Scanner; public class Myclass { public static void main(String [] args) { Scanner sc = new Scanner(System.in); String a; int b; System.out.println("enter a word"); a = sc.nextLine(); System.out.println("enter repetition"); b = sc.nextInt(); for ( int x=0; x < b; x++) { System.out.println(a); } } }

17th Sep 2016, 5:06 PM
logesh
3 Answers
+ 2
If you are trying sololearn compiler enter the string then the repetition in a new line insert your input like this: a 4
17th Sep 2016, 5:16 PM
Ahmad Samy
Ahmad Samy - avatar
+ 1
There is nothing 'wrong' with this code, I can run it and it will work fine. What isn't great is that there is not check to see if the second input is actually an integer at all
17th Sep 2016, 5:13 PM
Greg Sims
Greg Sims - avatar
0
use the eclipse
17th Sep 2016, 5:31 PM
Melan Rashitha
Melan Rashitha - avatar