Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started