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
igor_vitrenko [27]
3 years ago
8

Number pattern Write a recursive method called print Pattern() 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.

Engineering
2 answers:
ahrayia [7]3 years ago
4 0

Answer:

import java.util.Scanner;

public class NumberPattern {  

public static void printDec(int num1 , int num2)

{

   if(num1<0)

    return ;

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

   printDec(num1-num2,num2);

}

public static void printInc(int num1, int num2)

{

int curr = num1 - ((num1/num2)*num2);

curr = curr+num2;

printstart(num1,num2,curr);

}

public static void printstart(int num1 , int num2 , int curr)

{

    if(curr>num1)

     return;

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

    printstart(num1,num2,curr+num2);

}

public static void printNumPattern(int num1 , int num2)

{

  printDec(num1,num2);

  printInc(num1,num2);

}

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);

}

}

Explanation:

lilavasa [31]3 years ago
3 0

Answer:

See explaination

Explanation:

Code;

import java.util.Scanner;

public class NumberPattern {

public static int x, count;

public static void printNumPattern(int num1, int num2) {

if (num1 > 0 && x == 0) {

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

count++;

printNumPattern(num1 - num2, num2);

} else {

x = 1;

if (count >= 0) {

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

count--;

if (count < 0) {

System.exit(0);

}

printNumPattern(num1 + num2, num2);

}

}

}

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);

}

}

See attachment for sample output

You might be interested in
A plant has ten machines and currently operates two 8-hr shift per day, 5 days per week, 50 weeks per year. the ten machines pro
Zarrin [17]

Answer:

  83.6%

Explanation:

<h3>(a)</h3>

On its current schedule, the plant can theoretically produce ...

  (30 pc/h/machine)(10 machine)(8 h/shift)(2 shift/day)(5 day/wk)(50 wk/yr)

  = (30)(10)(8)(2)(5)(50) pc/yr = 1,200,000 pc/yr

__

<h3>(b)</h3>

On the proposed schedule, this production becomes ...

  (30 pc/mach)(10 mach)(8 h/sh)(3 sh/da)(6 da/wk)(51 wk/yr)

  = (30)(10)(8)(3)(6)(51) pc/yr = 2,203,200 pc/yr

The increase in capacity is ...

  (2,203,200/1,200,000 -1) × 100% = 83.6% . . . capacity increase

_____

<em>Additional comment</em>

The number of parts per shift did not change. Only the number of shifts per year changed. It went up by a factor of (3/2)(6/5)(51/50) = 1.836. Hence the 83.6% increase in capacity.

We have to assume that maintenance and repair are done as effectvely as before in the reduced down time that each machine has.

3 0
1 year ago
Please read and answer each question carefully.
Klio2033 [76]

the answer is (c)

After the vehicle is involved in a car accident or fire

5 0
3 years ago
2. There are three drawings that architects and designers use to indicate spaces. What are these drawing?
Zarrin [17]

Answer:

Architectural plans.

Explanation:

An architectural plan is called the drawings made by architects, civil engineers or designers of spaces or interiors, in which these professionals capture their building projects, organizing the distribution of the spaces to be used, the elements to be located in them and, fundamentally, to give construction planning a projection into reality. Thus, the plans help professionals to have a better understanding of the expected end result of the projects they are carrying out.

3 0
3 years ago
The cult of personality that surrounded Joseph Stalin in the Soviet Union led soviet citizens to believe that there was undisput
evablogger [386]

Answer:

The cult of personality that surrounded Joseph Stalin in the Soviet Union led soviet citizens to believe that there was undisputed support for Stalin both among the government and the common people. In turn, this fueled self-censorship and made political change harder. This cult of personality was achieved through propaganda and censorship, as the Communist Party had control of all mass media. This desire to make himself a "god-like" figure was also an attempt to increase acceptance of communism among the people and to boost morale.

Explanation:

7 0
2 years ago
Ô tô có khối lượng m (kg) đặt tại trung tâm h . Khoảng cách từ h tới 2 bánh xe hai bên của a (m) và b (m) , khoảng cách vết bánh
Nutka1998 [239]

Answer:

wiwhwnwhwwbbwbwiwuwhwhehehewhehehheheheehehehehhehehwh

Explanation:

jwhwhwhwhwhwwhhahwhahahwh

6 0
3 years ago
Other questions:
  • A stream of air enters a 7.00-cm ID pipe at a velocity of 30.0 m/s at 27.0°C and 1.80 bar (gauge). At a point downstrream, the a
    15·1 answer
  • // This program accepts data about 100 books and// determines a price for each.// The price is 10 cents per page for the// first
    12·1 answer
  • The crash rate per mile is.
    15·1 answer
  • The coefficient of performance of a reversible refrigeration cycle is always (a) greater than, (b) less than, (c) equal to the c
    12·1 answer
  • A railroad runs form city A to city B, a distance of 800km, through mountainous terrain. The present one-way travel time (includ
    13·1 answer
  • Consider the equation y = 10^(4x). Which of the following statements is true?
    9·1 answer
  • The hot-wire anemometer.' A hot-wire anemome ter is essentially a fine wire, usually made of platinum,which is heated electrical
    6·1 answer
  • 10) A pressure sensor consisting of a diaphragm with strain gauges bonded to its surface has the following information in its sp
    12·1 answer
  • 1. Band saw lower wheel does not require a guard *
    6·1 answer
  • When recycling paint booth filters, you must put them in an __________ container for transport as a solid waste.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!