Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete program named Test2.java with a method named printPattern and the main method. The printPattern method displays a pattern of n/2 rows

 

Write a complete program named Test2.java with a method named printPattern and the main method. The printPattern method displays a pattern of n/2 rows of ascending even numbers up to n. n should be passed to the method as a parameter. You can assume that n is an even number. public static void printPattern (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(); printPattern (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 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the complete program Test2java that implements the printPattern method and th... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Programming With Java A Problem Solving Approach

Authors: John Dean

3rd International Edition

1260575241, 9781260575248

More Books

Students also viewed these Programming questions

Question

Describe the parts of the self, according to William James.

Answered: 1 week ago

Question

Describe what this statement does: print user name = + userName

Answered: 1 week ago