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

Java programming lanuage please help as soon as possible Your assignment is to w

ID: 3775600 • Letter: J

Question

Java programming lanuage

please help as soon as possible

Your assignment is to write a program that draws rows and rows of triangles. It may be easier to view sample executions of such a program, and so I’ve included some below. Your program will read from an input file (“config.txt”) the size of each triangle and the number of rows of triangles using the Scanner technique covered in class or lab. In addition, your software will read in two characters from the input file, and use those characters to draw the triangle picture.

int //size
int //number of logos
char //first letter
char //second letter

__________

// end of .txt file

Program Requirements

There exists many ways to build this code, but the requirements stay the same. Your software should:

Read in 4 data items from a sequential text file using Scanner.

Draw a picture composed of triangles, using the input data to determine:

How large each triangle will be (triangle size)

How many rows of triangles will be displayed (row count)

What character should be used to draw the triangles (char 1)

A second character used to draw the space around the triangles (char 2)

Your output should be compared against the sample output for accuracy.

Note that the number of triangles drawn per row is directly proportional to the row count itself. So, for the first row, one triangle is drawn, and for the second row, two, and so on.

Loop(on number of rows)

      Loop(draw left border(s)) (0 to many times)

      Loop(draw triangle(s)) (0 to many times) //note this one step expands to a similar pattern

      Loop(draw right border(s)) (0 to many times)

triangle Size triangleRows output Ar A A A A A A A A A A Character 1 Character 2

Explanation / Answer

import java.util.*;

public class Prog673A

{

    public static void leftTriangle()

    {

        Scanner input = new Scanner (System.in);

      System.out.print("How many rows: ");

        int rows = input.nextInt();

        for (int x = 1; x <= rows; x++)

        {

            for (int i = 1; i <= x; i++)

            {

                System.out.print("*");

            }

            System.out.println("");

        }

    }

    public static void rightTriangle()

    {

        Scanner input = new Scanner (System.in);

        System.out.print("How many rows: ");

        int rows = input.nextInt();

        for (int x = 1; x <= rows; x++)

        {

            for (int i = 1; i >= x; i--)

            {

                System.out.print(" ");

            }

            System.out.println("*");

        }

    }

    public static void centerTriangle()

    {

    }

    public static void main (String args [])

    {

        Scanner input = new Scanner (System.in);

        System.out.println("Types of Triangles");

        System.out.println(" 1. Left");

        System.out.println(" 2. Right");

        System.out.println(" 3. Center");

        System.out.print("Enter a number: ");

        int menu = input.nextInt();

        if (menu == 1)

            leftTriangle();

        if (menu == 2)

            rightTriangle();

        if (menu == 3)

            centerTriangle();

    }

}

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