Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to write a Java program that prints out the following triangles exactly. Here is the parameters of the Java program: package assignment1; public

I need to write a Java program that prints out the following triangles exactly.

image text in transcribed

Here is the parameters of the Java program:

package assignment1;

public class Assignment1 {

private final int HEIGHT = 11; public enum Patterns{ bottomLeftTriangle, bottomRightTriangle, topLeftTriangle, topRightTriangle, centerTriangle, }; // Write details of your algorithm void printCenter(char ch){ } // Write details of your algorithm void printBottomLeft(char ch){ } // Write details of your algorithm void printTopLeft(char ch){ } // Write details of your algorithm void printBottomRight(char ch){ } // Write details of your algorithm void printTopRight(char ch){ } /* * This function according to the pattenId calls the appropriate print function * with the input ch. Default printTopLeft is called. * */ public void printPattern(Patterns patternId, char ch){ switch (patternId){ case bottomLeftTriangle: this.printBottomLeft(ch); break; case bottomRightTriangle: this.printBottomRight(ch); break; case topLeftTriangle: this.printTopLeft(ch); break; case topRightTriangle: this.printTopRight(ch); break; case centerTriangle: this.printCenter(ch); break; default: this.printTopLeft(ch); break; } } /** * @param args the command line arguments */ public static void main(String[] args) { Assignment1 ass1 = new Assignment1(); ass1.printPattern(Assignment1.Patterns.bottomLeftTriangle, '*'); ass1.printPattern(Assignment1.Patterns.bottomRightTriangle, '#'); ass1.printPattern(Assignment1.Patterns.topLeftTriangle, '@'); ass1.printPattern(Assignment1.Patterns.topRightTriangle, '%'); ass1.printPattern(Assignment1.Patterns.centerTriangle, '^'); } }

Develop a class in Java which produces the following outputs according to the input parameters kx aaaaaa $$$$ kxx % % kx*kxx kx**kx - Your program is going to draw 5 different triangles, (1) left-bottom right triangle, (2) right-bottom right triangle, (3) left-top right triangle, (4) right-top right triangle, (5) isosceles triangle with fixed height -You are going to use the framework ( Assignment 1.java - I Implement the 5 print functions Update access modifiers of these 5 print functions - For the isosceles triangle, since you know the height, first you need to compute the base, and then, start drawing (base -1)/2 (base -3)/2 AXa (base -5)/2 5 height base

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

14-18 Compare the two major types of planning and control tools.

Answered: 1 week ago