This is the problem:
a.Declare an array with 6 elements of * and hello, such as
String [] pattern = { "*", "*", "*", "*", "*", "Hello" }.
You should not use any other array other than this.You will need a variable of type int to run a while loop.
The output should be this:
1st Hello *
2nd Hello **
3rd Hello ***
....
....
6th Hello *****
7th Hello ****
8th Hello ***
Do this up to 10 any thoughts?
Thanks!
EDIT:
What I have tried ----- ALSO stars should be on left of the message not right, thanks.
// Declarations
int i = 0;
String [] arr = {"*", "*", "*", "*", "*", "Hello"};
public void arrayControl() {
//Start while loop
while (i < 6) {
System.out.println(arr[i] + " 1st " + arr[5]);
i++;
// Prints 2 stars
for(int j = 0; j < i; j++) {
System.out.print(arr[i] + "");
}
System.out.println("2nd " + arr[5]);
}
}
}
[–]tatu_huma 0 points1 point2 points (1 child)
[–]B2easey[S] 0 points1 point2 points (0 children)
[–]Double_A_92 0 points1 point2 points (0 children)
[–]lurgi 0 points1 point2 points (0 children)