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
What happens in double transverse wishbone front suspension when brakes are applied.
RideAnS [48]

Answer:

When the brakes are applied the in the typical double transverse wishbone front suspension,  it "drives" the car ground due to the setting of the link-type system pivot points on the lower wishbone are have parallel alignment to the road

Explanation:

In order to minimize the car's reaction to the application of the brakes, the front and rear pivot are arranged with the lower wishbone's rear pivot made to be higher than the front pivot as such the inclined wishbone torque results in an opposing vertical force to the transferred extra weight from the back due to breaking.

5 0
3 years ago
Differences between acidic and basic Bessemer process​
dybincka [34]

Answer:

In the acid processes, deoxidation can take place in the furnaces, leaving a reasonable time for the inclusions to rise into the sla*g and so be removed before casting. Whereas in the basic furnaces, deoxidation is rarely carried out in the presence of the sla*g, otherwise phosphorus would return to the metal.

5 0
2 years ago
Distinguish between systems analysis and systems design?
Zielflug [23.3K]

Answer:

System analysis can be defined as a deep analysis of a part of the structure of a module that has been designed before. System design means to make any module or a part of the structure from scratch and build it completely without estimation.

Explanation:

3 0
3 years ago
What should be given to a customer before doing a repair?
natima [27]
A. I believe, lmk if I’m right
7 0
3 years ago
In Lab 7, we worked through a program that displayed the homeless shelter occupancy over time. The same approach can be used for
Bezzdna [24]

Answer:

Explanation:

The python code to generate this is quite simple to run.

i hope you understand everything written here, you can as well try out other problems to understand better.

First to begin, we import the package;

Code:

import pandas as pd

import matplotlib.pyplot as plt

name = input('Enter name of the file: ')

op = input('Enter name of output file: ')

df = pd.read_csv(name)

df['Date'] = pd.to_datetime(df["Date"].apply(str))

plt.plot(df['Date'],df['Absent']/(df['Present']+df['Absent']+df['Released']),label="% Absent")

plt.legend(loc="upper right")

plt.xticks(rotation=20)

plt.savefig(op)

plt.show()

This should generate the data(plot) as seen in the uploaded screenshot.

thanks i hope this helps!!!

6 0
2 years ago
Other questions:
  • The density of oxygen contained in a tank is 2.0 kg/m3 when the temperature is 25 °C. Determine the gage pressure of the gas if
    12·1 answer
  • Make a proposal to add a small pizza shop to a historical part of town. How could it be designed to “fit” into the area?
    7·2 answers
  • The displacement volume of an internal combustion engine is 3 liters. The processes within each cylinder of the engine are model
    10·1 answer
  • A stainless-steel specimen from the same material characterized up above, was formed into a rectangular cross-section of dimensi
    9·1 answer
  • MCQ : What are the main the constituents of acid rains?
    10·2 answers
  • The insulator is the connection between the grounded circuit conductor and the equipment grounding conductor at the service.
    15·1 answer
  • An intelligence signal is amplified by a 65% efficient amplifier before being combined with a 250W carrier to generate an AM sig
    5·1 answer
  • What is the difference between a series circuit and a parallel circuit?
    11·2 answers
  • All of these are true about a magnesium part EXCEPT that it:
    8·1 answer
  • What color is a board sternlight
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!