public static void print Pattern (int n) The main method that calls printPattern is given below: public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner (System.in); // Prompt the user to enter the number of lines System.out.print ("Enter an even number between 2 to 20: "); int patternTarget input.nextInt (); = print Pattern (patternTarget); } Here are three sample outputs when the program is executed: Enter an even number between 2 to 20: 10 2 24 246 2468 2 4 6 8 10 Enter an even number between 2 to 20: 2 2 Enter an even number between 2 to 20: 20 2 24 246 2468 2 4 6 8 10 2 4 6 8 10 12 2 4 6 8 10 12 14 2 4 6 8 10 12 14 16 2 4 6 8 10 12 14 16 18 2 4 6 8 10 12 14 16 18 20

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 13RQ
icon
Related questions
Question

Consider n as an even number and n is passted to the method as a parameter. Need help writing the program and the display result need to be as shown in the image attatched.

public static void print Pattern (int n)
The main method that calls print Pattern is given below:
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner (System.in);
// Prompt the user to enter the number of lines
System.out.print ("Enter an even number between 2 to 20: ");
int patternTarget = input.nextInt ();
print Pattern (patternTarget);
}
Here are three sample outputs when the program is executed:
Enter an even number between 2 to 20: 10
2
24
246
2468
2 4 6 8 10
Enter an even number between 2 to 20: 2
2
Enter an even number between 2 to 20: 20
2
24
246
2468
2 4 6 8 10
2 4 6 8 10 12
2 4 6 8 10 12 14
2 4 6 8
10 12 14 16
2 4 6 8 10 12 14 16 18
2 4 6 8 10 12 14 16 18 20
Transcribed Image Text:public static void print Pattern (int n) The main method that calls print Pattern is given below: public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner (System.in); // Prompt the user to enter the number of lines System.out.print ("Enter an even number between 2 to 20: "); int patternTarget = input.nextInt (); print Pattern (patternTarget); } Here are three sample outputs when the program is executed: Enter an even number between 2 to 20: 10 2 24 246 2468 2 4 6 8 10 Enter an even number between 2 to 20: 2 2 Enter an even number between 2 to 20: 20 2 24 246 2468 2 4 6 8 10 2 4 6 8 10 12 2 4 6 8 10 12 14 2 4 6 8 10 12 14 16 2 4 6 8 10 12 14 16 18 2 4 6 8 10 12 14 16 18 20
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage