Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that prints the pattern shapes below (A, B, C, D, E). Your progr

ID: 3616981 • Letter: W

Question

Write a program that prints the pattern shapes below (A, B, C, D, E). Your program must use loops (while, do-while, and/or for loops with nest-for). You may use System.out.printf( ), System.out.print( ), or System.out.println( ) methods to print either a single asterisk (*) or a single blank. Maximize your use of for loops with nested-for and minimize the number of print statements.

All asterisks should be printed by a single print statement of the form print(“*”) which causes the asterisks to print side by side. [Hint: Patterns C & D require that each line begin with an appropriate number of blanks.]

Your program should ask the user for the pattern to draw (A, B, C, D, or E). When choosing a pattern , the program should ask for the size of the largest line or the diamond (in case of package E, which should be an odd number within the range of 1 à 21). For the rest of the shapes, the size could be odd or even (also from 1à21). Once the diamond of the appropriate size is displayed (or any other shape), the program should ask the user to continue or quit.

        *                           ********                    ********                                 *

        **                         *******                      *******                                 **

        ***                       ******                            ******                               ***

        ****                     *****                                *****                             ****

        *****                   ****                                    ****                           *****

        ******                 ***                                        ***                         ******

        *******               **                                            **                       *******

        ********             *                                                *                    ********

(A)                   (B)                                            (C)                            (D)

                                                             *

                                                           ***

                                                         *****

                                                       *******   This is a diamond o

Explanation / Answer

please rate - thanks import java.util.*; public class shapes { public static void main(String []args) {Scanner in=new Scanner(System.in); int max; char shape; char done='Y'; while(done=='Y') { System.out.print("Enter shape to print (A,B,C,D,E): "); shape=Character.toUpperCase(in.next().charAt(0)); do      {       System.out.println("Enter size atwidest point-for E must be odd: ");       max=in.nextInt();      }while(shape=='E'&&max%2!=1); if(shape=='A')      drawA(max); else if(shape=='B')      drawB(max); else if(shape=='C')      drawC(max); else if(shape=='D')      drawD(max); else if(shape=='E')      drawE(max); else      System.out.println("Invalid shapechosen!"); System.out.print("Draw another shape? "); done=Character.toUpperCase(in.next().charAt(0));    } } public static void drawC(int n)    {int i,j,k;    for(j=1;j
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote