I need help making a program that lets you specify the dimensions of an arrow in console.
import java.util.Scanner;
public class Project6 {
public static void main(String[] args) {
int height = 0;
int width = 0;
boolean run = true;
Scanner scanner = new Scanner(System.in);
int rows = 0;
while (run) {
System.out.println("Please Specify The Demensions of Your Arrow:");
System.out.print("\tHeight: ");
if (!(scanner.hasNextInt())) {
System.out.println("Please Enter an Integer.");
} else {
height = scanner.nextInt();
if (!(height > 0)) {
if (height == -1) {
break;
} else {
System.out.println("Please Enter A Positive Integer");
}
} else {
System.out.print("\tWidth: ");
if (!(scanner.hasNextInt())) {
System.out.println("Please Enter An Integer");
} else {
width = scanner.nextInt();
if (!(width > 0)) {
if (width == -1) {
break;
} else {
System.out.println("Please Enter A Positive Integer");
}
}
}
}
if (width % 2 == 0) {
System.out.println("Width is an Even Number");
} else {
System.out.println("Width is odd");
for (int numRow = width; numRow >= 1; numRow -= 2) {
System.out.println(numRow);
rows++;
}
System.out.println("Number of Rows: " + rows);
}
/*if(height % 2 == 0) {
System.out.println("height is an Even Number");
} else {
System.out.println("height is odd");
for(int numCol = height; numCol >= 1; numCol -=2) {
System.out.println(numCol);
}
}*/
}
}
}
}
I put a part in comments because I wasn't sure if I wanted to keep it or not. This is as far as I could get. I have no clue where to go from here. Essentially what I'm trying to do is, for example: you input height: 10
and width: 9
and it looks like this:
*
***
*****
*******
*********
***
***
***
***
***