Write a method to display a pattern as follows:
1
1 2
1 2 3
...
...
1 2 3 4 5 ... n
The method header is
public static void displayPattern(int n)
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Enter the side of the pentagon
System.out.print("Enter n: ");
int n = input.nextInt();
displayPattern(n);
}
public static void displayPattern(int n) {
// Fill in the code here
}
}
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q7: Analyze the following code: public class Test
Q8: What is the value in count after
Q9: If you attempt to add an int,
Q10: What is i after the following for
Q11: What is the number of iterations in
Q13: What is Math.floor(3.6)?
A) 5.0
B) 3
C) 3.0
D)
Q14: Analyze the following code. public class Test
Q15: _ is to implement one method in
Q16: What is the output for y?
int
Q17: The following code displays _.
double temperature
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents