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

In Java: For this project, create a java program that includes the main method a

ID: 3770879 • Letter: I

Question

In Java:

For this project, create a java program that includes the main method and three other methods. These methods can all be part of the same class or you can create a separate class for the three methods listed below (optional). The lab activity Hello World with Class demonstrates this approach. Here are the three methods that are required in addition to the main method.

drawLine: This method will display a line using asterisks

drawRectangle: This method will display a rectangle using asterisks

drawTriangle: This method will display a triangle using asterisks

The main method should display a label and call (activate) each method to display each shape. For example, the main method should display the label "Triangle", then display a triangle shape made of asterisks.

Then, the main method should display a label and call the methods again, but in a different order so the combined shapes make the more complex shapes. The labels should be: pine tree, house and beaker. Do not create a separate method for each complex shape. Instead, you must call one or more of the drawLine, drawRectagle and/or drawTriangle methods necessary to create these complex shapes.

The output must look like the example below:

Minimum Requirements:

1. This program must contain a total of four methods including main as described above.   You can only use System.out.println statements in the methods. (10 points)

Important Note: If you decide to use an example from the Internet for this, you must modify the example to remove any extra code (loops, for, do, while, if, switch etc) so that the functions contain only System.out.println statements and organize the code into the required methods.

2. The main method should display the labels for each shape as shown in the example output, then call (activate) each method as needed, so the functions display the desired shapes. Follow the display order shown on the example output. (10 points).

Explanation / Answer

import java.io.*;

import java.util.*;

import java.util.Scanner;

class StarShapes

{

public static void main(String [] args)

{

int lengthL;

int lengthR, breadthR;

int rowsT;

System.out.println("enter your choice to print shape");

System.out.println("1: Line 2: Rectangle 3: triangle 4: pineTree 5: House 6: Beakar");

Scanner s= new Scanner(System.in);

int choice = s.nextInt();

switch(choice)

{

case 1:

System.out.println("Line");

drawLine();

break;

case 2:

System.out.println("Rectangle");

drawRectangle();

break;

case 3:

System.out.println("Triangle");

drawTriangle();

break;

case 4:

System.out.println("Pine Tree");

drawPine();

break;

case 5:

System.out.println("House");

drawHouse();

break;

case 6:

System.out.println("Beaker");

drawBeakar();

break;

default:

System.out.println("enter correct choice");

break;

}

void drawLine()

{

System.out.println("enter which type of line you want: 8:Vertical or 9:Horizontal");

int ch= s.nextInt();

switch(ch)

{

case 8:

System.out.print("*");

System.out.println("*");

System.out.println("*");

System.out.println("*");

System.out.println("*");

System.out.println("*");

System.out.println("*");

break;

case 9: System.out.println("Line");

System.out.print("*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");

break;

default: System.out.println("please enter correct choice from 8 or 9");

break;

}

}

void drawRectangle()

{

System.out.println("enter which type of Rectangle you want: 10:Vertical or 11:Horizontal");

int ch= s.nextInt();

switch(ch)

{

case 10:

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

break;

case 11:

System.out.print("*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*"+" "+"*"+" "+"*");

break;

default:

System.out.println("please enter correct choice from 10 or 11");

break;

}

}

void drawTriangle()

{

System.out.println("enter which type of Triangle you want: 12:pointing upwords or 13:pointing down");

int ch= s.nextInt();

switch(ch)

{

case 12:

System.out.print(" "+" "+" "+"*");

System.out.println();

System.out.print(" "+" "+"*"+" "+"*");

System.out.println();

System.out.print(" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

break;

case 13:

System.out.print("*"+" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print(" "+"*"+" "+"*"+" "+"*");

System.out.println();

System.out.print(" "+" "+"*"+" "+"*");

System.out.println();

System.out.print(" "+" "+" "+"*");

break;

default:

System.out.println("enter the correct choice");

break;

}

}

void drawPine()

{

drawTriangle();

System.out.println("plase chose case 12");

System.out.println();

System.out.print(" "+" "+" ");

drawLine();

System.out.println("please enter choice 8");

}

drawHouse()

{

drawTriangle();

System.out.println("please choose case 12");

System.out.println();

drawRectangle();

System.out.println("please choose case 11");

}

drawBeakar()

{

System.out.println("please choose choice 10");

drawRectangle();

}

}

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