#what could i make thats simple but cool for my ascii coding project any ideas? i have my code below
1 messages · Page 1 of 1 (latest)
<@&987246527741304832> please have a look, thanks.
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the type of shape (triangle, rectangle, diamond):");
String shapeType = scanner.nextLine().toLowerCase();
System.out.println("Enter the size of the shape:");
int size = scanner.nextInt();
scanner.nextLine(); // consume newline character
System.out.println("Enter the character for the shape:");
char character = scanner.nextLine().charAt(0);
if (shapeType.equals("triangle")) {
for (int i = 1; i <= size-(size/2); i++) {
for (int j = i; j <= size/2; j++) {
System.out.print(" ");
}
for (int j = 1; j < i; j++) {
System.out.print(character);
}
for (int j = 1; j <= i; j++) {
System.out.print(character);
}
System.out.println();
}
} else if (shapeType.equals("rectangle")) {
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
System.out.print(character);
}
System.out.println();
}
} else if (shapeType.equals("diamond")) {
for (int i = 1; i <= size-(size/2); i++) {
for (int j = i; j <= size/2; j++) {
System.out.print(" ");
}
for (int j = 1; j < i; j++) {
System.out.print(character);
}
for (int j = 1; j <= i; j++) {
System.out.print(character);
}
System.out.println();
}
for (int i = 1; i <= size-(size/2); i++) {
for (int j = 1; j <= i; j++) {
System.out.print(" ");
}
for (int j = i; j < size/2; j++) {
System.out.print(character);
}
for (int j = i; j <= size/2; j++) {
System.out.print(character);
}
System.out.println();
}
} else {
}
}
}```