67 232
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #9102 in Java | JSP | JSF for tarik

Question #9102
write java applications that print the following pyramid using an array.
User must enter the number of start to displays.
Example: Please enter the number of stat to displays: 6.
*
**
***
****
*****
******
Expert's answer
import java.util.Scanner;
public class Main {


public static void main(String[] args) {
int numberofstat=0;
Scanner input = new Scanner(System.in);
System.out.print("Please enter the number of stat to displays: ");
numberofstat =input.nextInt();
String str="";
for(int i=0;i<numberofstat;i++){
str+="*";
System.out.print(str+"
");
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions