i have a problem with a little java program.
I have to type a number between 1 and 10. This number represents the number of lines. For example: If you type 4, the following image is displayed.
o
oo
ooo
oooo
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
int number, count;
System.out.println("Write the number from 1 to 10");
Scanner teklatua = new Scanner(System.in);
String datu = teklatua.nextLine();
number = Integer.parseInt(datu);
if(number> 10 || number< 1)
{
System.out.println(number + " not between 1 and 10, choose again");
}
else
{
for (count=1; count<=number ; count++)
{
System.out.println("o");
for (count=1; count<=number; count++)
{
System.out.print("o");
}
}
}
}
}
Thanks!!
Edit:
Sorry, my problem was that the execution of the code gives me:
o
oooo
and I did not know how to solve it