I can’t get started on my Java homework?

Hello there, I just started any Java category, and Thought about never apply Java in advance of.And I’m undecided I actually understand the direction to go…
Thus, help please!!

Write an opportunity, using two nested loops (one inside the other) which displays a triangle connected with stars as shown below in the terminal:

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

The height (in lines) with the triangle is often a number entered with the user.
Illustration:java Triangle 4
*
**
***
****

Modify this course in question 1 so that it units trees because below:
A
*******
******
*****
****
***
**
*

B
*
***
*****
*******
*********
***********
*************

Here’s the actual code regarding it

significance java.io.*;

training Program

open public static useless main(String args)

if(args.length>0)

int d = Integer.parseInt(args0);
for(int i=0; i<c; i++)

for(int j=0; j<(i+1); j++)

Process.out.print(“*”);

Process.out.print(“\n”);

In the event that input is usually 4, then
*
**
***
****

Regarding program A
significance java.io.*;

training Program

open public static useless main(String args)

if(args.length>0)

int d = Integer.parseInt(args0);
for(int i=c; i>0; i–)

for(int j=0; j<i; j++)

Process.out.print(“*”);

Process.out.print(“\n”);

In the event that input is usually 4
****
***
**
*

Computer code for application B
training Program

open public static useless main(String args)

if(args.length>0)

int d = Integer.parseInt(args0);
int times;
for(int i=0; i<c; i++)

x=2*(i);
if((x%2)==0)
x++;
for(int j=0; j<x; j++)

Process.out.print(“*”);

Process.out.print(“\n”);

In the event that input is usually 4,
*
***
*****
*******

Thanks, Hope it helps.

Leave a Reply