1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kap26 [50]
3 years ago
13

Write a recursive method called printNumPattern() to output the following number pattern.Given a positive integer as input (Ex:

12), subtract another positive integer (Ex: 3) continuallyuntil 0 or a negative value is reached, and then continually add the second integer until therst integer is again reached. For this lab, do not end output with a newline.
Computers and Technology
1 answer:
aleksley [76]3 years ago
6 0

Answer:

Explanation:

The following is written in Java and prints out the pattern to and from the first num parameter that is passed to the function. Meaning it goes from num1 to 0 and then from 0 to num1 again. It prints all of the values in a single line seperated by a space and a test case was used using the values provided in the question. The output can be seen in the attached picture below.

static void printNumPattern(int n1,int n2){

       System.out.print(n1 + " ");

       if(n1<=0) {

           return;

       } else {

           printNumPattern(n1-n2,n2);

       }

       System.out.print(n1 + " ");

   }

You might be interested in
Which group allows you to add notes to your presentation?
aleksandrvk [35]

Answer:

Presentation views

Explanation:

6 0
3 years ago
Read 2 more answers
When is founded by java
Rina8888 [55]
Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle) and released in 1995 as a core component of Sun Microsystems' Java platform
1995 the answer
4 0
3 years ago
Read 2 more answers
Can someone tell me what this means Higfaa
Arisa [49]

Answer:

it's a Jamaican slang

Explanation:

it depends on the wah it is used

7 0
3 years ago
Sally notices that she has the same set of 10 blocks in her code in multiple places. She decides to create a new block (procedur
SashulF [63]

Answer: it is C. 41

Explanation: i no it

6 0
3 years ago
____ privileges for data involve establishing who can enter new data, change existing data, delete unwanted data, and view data.
Stolb23 [73]
Administrator privileges
6 0
3 years ago
Other questions:
  • If you are trying to create a web page for your band and having difficulty creating links to other groups on your page, what is
    7·1 answer
  • Kwan is using JavaScript extensively to add interactivity to his Web site. Contained within his script is a counter object that
    8·1 answer
  • He primary purpose for attackers to send port scanning probes to hosts is to identify which ports are open. true false
    5·1 answer
  • You've created a letter from a blank document. To format this letter with a unified font, colors, and effects you'll apply a A.g
    6·2 answers
  • What will you personally do to make your peers aware of the seriousness Of teen crashes?
    9·1 answer
  • Explain briefly the purpose of the Computer Management Console in Microsoft Windows.
    12·1 answer
  • Create the following new exceptions: PokemonException, which extends the Exception class. It must have a no-parameter constructo
    13·1 answer
  • How was the addition of an improvement over early web design?
    11·1 answer
  • Write down a scratch program which:
    5·1 answer
  • HELP ME ILL GIVE BRAINLY Input 50 numbers and then output the average of the negative numbers only. Write in pseudocode!
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!