Question: This is my Java code. import java.util.Scanner; class RunQuad { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println(Press R for Rectangle,

This is my Java code.

import java.util.Scanner;

class RunQuad {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("Press R for Rectangle, S for Square, P for Parallelogram, H for Rhombus, or T for Trapezoid.");

char choice = input.nextLine().toUpperCase().charAt(0);

Quadrilateral quadrilateral;

switch (choice) {

case 'R':

quadrilateral = new Rectangle();

break;

case 'S':

quadrilateral = new Square();

break;

case 'P':

quadrilateral = new Parallelogram();

break;

case 'H':

quadrilateral = new Rhombus();

break;

case 'T':

quadrilateral = new Trapezoid();

break;

default:

System.out.println("Invalid input.");

return;

}

quadrilateral.showDescription();

}

}

abstract class Quadrilateral {

public void showDescription() {

System.out.println("- is quadrilateral");

}

}

class Rectangle extends Quadrilateral {

public void showDescription() {

super.showDescription();

System.out.println("- has 4 right angles");

}

}

class Square extends Rectangle {

public void showDescription() {

super.showDescription();

System.out.println("- has 4 equal sides");

}

}

class Parallelogram extends Quadrilateral {

public void showDescription() {

super.showDescription();

System.out.println("- has 2 pairs of parallel sides");

}

}

class Rhombus extends Parallelogram {

public void showDescription() {

super.showDescription();

System.out.println("- has 4 congruent sides");

}

}

class Trapezoid extends Quadrilateral {

public void showDescription() {

super.showDescription();

System.out.println("- has 1 pair of parallel sides");

}

}

This is my Java code. import java.util.Scanner; class RunQuad { public static

Please put the part where if you inputted a letter, it says what shape like on the sample output. "A square:" if it's a square, "A Rhombus:" if it's a rhombus... and so on.

Thank you so much in advance.

Sample Output: Press R for Rectangle or S for Square. S A square: - has 4 equal sides - has 4 right angles - is quadrilateral

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!