Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the triangle examples left justified and right justified, and the class Triangle from the book to assist you in the following: Analyze the problem

Use the triangle examples left justified and right justified, and the class Triangle from the book to assist you in the following:

  1. Analyze the problem of having a class that represents triangles and prints a figure representation of the triangle to the screen.
  2. Design a Java solution to this problem.
  3. Implement a Java solution based upon your design.

class RightTriangleLeftJustifiedInMain { public static void main(String args[]) { int row, col; System.out.println(); for(row = 1; row < 6; row++) { for(col = 1; col <= row; col++) { System.out.print(row); } System.out.println(); } System.out.println(); } }
class RightTriangleRightJustifiedInMain { public static void main(String args[]) { int row, col; System.out.println(); System.out.println("Process #1 for printing the Triangle"); System.out.println(); for(row = 1; row < 6; row++) { for(col = 1; col < 6 - row; col++) { System.out.print(" "); } for(; col < 6; col++) { System.out.print(row); } System.out.println(); } System.out.println(); System.out.println("Process #2 for printing the Triangle"); System.out.println(); for(row = 1; row < 6; row++) { for(col = 1; col < 6; col++) { if(col < 6 - row) { System.out.print(" "); } else { System.out.print(row); } } System.out.println(); } System.out.println(); } }

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

Step: 3

blur-text-image

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

What are some of the events that might lead to the disposal of PPE?

Answered: 1 week ago

Question

6. Write a job specification.

Answered: 1 week ago