Question: Java The objective is to print a parallelogram based off the user's input of the height, width and character. I've figured out how to input
Java
The objective is to print a parallelogram based off the user's input of the height, width and character. I've figured out how to input the height, width and character, where I'm struggling is figuring out how to print the shape
My code thus far:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Double height; Double width; String entry; System.out.println("Enter height: "); height = scan.nextDouble(); if (height < 2) { System.out.println("Invalid choice, number must be greater than 2 and less than 8"); System.out.println("Enter height: "); height = scan.nextDouble(); } if (height > 8) { System.out.println("Invalid choice, number must be greater than 2 or less than 8"); System.out.println("Enter height: "); height = scan.nextDouble(); } System.out.println("Enter width: "); width = scan.nextDouble(); if (width < 2) { System.out.println("Invalid choice, number must be greater than 2 or less than 8"); System.out.println("Enter width: "); width = scan.nextDouble(); } if (width > 8) { System.out.println("Invalid choice, number must be greater than 2 or less than 8"); System.out.println("Enter width: "); width = scan.nextDouble(); } System.out.println("Enter character: "); entry = scan.nextLine(); if (entry.matches("[A-Za-z0-9]+")) { } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
