subject
Mathematics, 14.02.2020 16:30 camiilajakobsen1400

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) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached.

Ex. If the input is

12
3
the output is

12 9 6 3 0 3 6 9 12
Code Below:

import java. util. Scanner;

public class NumberPattern {
// TODO: Write recursive printNumPattern() method

public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int num1;
int num2;

num1 = scnr. nextInt();
num2 = scnr. nextInt();
printNumPattern(num1, num2);

ansver
Answers: 3

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 14:50, amcdaniel1
Which function has the same domain as y=2x
Answers: 1
image
Mathematics, 21.06.2019 23:30, saintsfan2004
Arestaurant added a new outdoor section that was 8 feet wide and 6 feet long. what is the area of their new outdoor section
Answers: 1
image
Mathematics, 22.06.2019 00:30, emilyf05
You eat $0.85 for every cup of hot chocolate you sell. how many cups do you need to sell to earn $55.25
Answers: 2
image
Mathematics, 22.06.2019 01:20, ctyrector
Anita has a success rate of 80% on free throws in basketball. she wants to know the estimated probability that she can make exactly four of five free throws in her next game. how can she simulate this scenario? categorize each simulation of this scenario as correct or incorrect.
Answers: 2
You know the right answer?
Write a recursive method called printNumPattern() to output the following number pattern.

Questions in other subjects:

Konu
Mathematics, 06.03.2020 17:05