Is their a better way to format this for-loop?
The user enters two integers which are initialised to x and y the program prints these values out as + for the first number and - for the second number.
FOR EXAMPLE 9 and 5 would result in
+++++++++-----
I tried using a nested for-loop, but this resulted in
+-----+-----+-----+-----+-----+-----+-----+-----+-----
Scanner sc = new Scanner(System.in);
int x,y,total = 0;
System.out.println("Enter two numbers greater than 0 and no greater than 20!");
x = sc.nextInt();
y = sc.nextInt();
draw(x,y);
private static void draw(int x, int y) {
for(int i=1; i<=x; i++)
{
System.out.print("+");
}
for(int j=1; j<=y; j++)
{
System.out.print("-");
}
}