answer.
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
max2010maxim
19 days 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:
mote1985 [204]19 days ago
4 0

Response:

import java.util.Scanner;

public class NumberPattern {  

public static void decrement(int num1, int num2)

{

   if(num1 < 0)

    return;

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

   decrement(num1 - num2, num2);

}

public static void increment(int num1, int num2)

{

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

current = current + num2;

begin(num1, num2, current);

}

public static void begin(int num1, int num2, int current)

{

    if(current > num1)

     return;

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

    begin(num1, num2, current + num2);

}

public static void displayNumPattern(int num1, int num2)

{

  decrement(num1, num2);

  increment(num1, num2);

}

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int num1;

int num2;

num1 = scnr.nextInt();

num2 = scnr.nextInt();

displayNumPattern(num1, num2);

}

}

Clarification:

alex41 [274]19 days ago
3 0

Response:

Refer to the explanation

Clarification:

Code:

import java.util.Scanner;

public class NumberPattern {

public static int x, count;

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

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

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

count++;

displayNumPattern(num1 - num2, num2);

} else {

x = 1;

if (count >= 0) {

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

count--;

if (count < 0) {

System.exit(0);

}

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

displayNumPattern(num1, num2);

}

}

See attached example output

You might be interested in
All MOS devices are subject to damage from:________
Viktor [230]

Answer:

d. all of these

Explanation:

Electrostatic discharge typically generates a high voltage in a localized area, leading to increased current and heat. It can create craters in an MOS device, damage bond wires, or result in other forms of impairment. Essentially, MOS devices are vulnerable to harm from "all of these."

6 0
22 days ago
6. You are evaluating flow through an airway. The current flow rate is 10 liters per minute with a fixed driving pressure (P1) o
iogann1982 [279]

Answer:

B) P1 would have to increase to sustain the flow rate (correct)

C) Resistance would rise (correct)

Explanation:

Flow rate is measured at 10 liters per minute

Driving pressure (P1) stands at 20 cm H2O

Fixed downstream pressure (P2) is 5 cm H2O

The accurate statements when the lumen is pinched in the center of the tube are: P1 will increase to maintain the flow rate, and resistance will rise. This occurs because pinching the lumen decreases its diameter, leading to higher resistance, which is linearly related to pressure, thus P1 will also increase.

The incorrect statement is: the flow would decrease.

6 0
16 days ago
The rigid beam is supported by a pin at C and an A992 steel guy wire AB of length 6 ft. If the wire has a diameter of 0.2 in., d
Mrrafil [253]

Answer:

Change in length = 0.0913 in

Explanation:

Given data:

Length = 6 ft

Diameter = 0.2 in

Load w = 200 lb/ft

Solution:

We start by applying the equilibrium moment about point C, expressed as

∑M(c) = 0.............1

This can be used to find the force in AB.

10× 200 × ( 5) - (T cos(30)) × 10 = 0

Solving gives us

Tension in wire T(AB) = 1154.7 lb

We also know the modulus of elasticity for A992 is

E = 29000 ksi

And the area will be

Area = \frac{\pi }{4}\times 0.2^2

The change in length is expressed as

Change in length = \frac{PL}{AE}.........2

Substituting values results in

Change in length = \frac{1154.7 \times 6 \times 12}{\frac{\pi }{4}\times 0.2^2 \times 29000 \times 1000}

Change in length = 0.0913 in

8 0
26 days ago
Describe the grain structure of a metal ingot that was produced by slow-cooling the metal in a stationary open mold.
pantera1 [220]
In the scenario of a metal ingot cooling slowly, the microstructure tends to be coarse. The surface, exposed to higher temperatures for extended periods during cooling, features smaller grain sizes as they have less time to form. However, as we delve deeper into the ingot, the grains gradually extend, leading to equiaxed grain formation at the center.
6 0
7 days ago
Helium gas is compressed from 90 kPa and 30oC to 450 kPa in a reversible, adiabatic process. Determine the final temperature and
choli [191]

Answer:

T2 ( final temperature ) = 576.9 K

a) 853.4 kJ/kg

b) 1422.3 kJ / kg

Explanation:

given data:

pressure ( P1 ) = 90 kPa

Temperature ( T1 ) = 30°c + 273 = 303 k

P2 = 450 kPa

To determine final temperature in an Isentropic process

T2 = T1 (\frac{p2}{p1} )^{(k-1)/k} ----------- ( 1 )

T2 = 303 ( \frac{450}{90})^{(1.667- 1)/1.667} = 576.9K

The work performed in a piston-cylinder device is calculated using the subsequent formula

w_{in} = c_{v} ( T2 - T1 )    ------- ( 2 )

where: cv = 3.1156 kJ/kg.k for helium gas

             T2 = 576.9K,    T1 = 303 K

substituting values into equation 2

w_{in} = 853.4 kJ/kg

the work done in a steady flow compressor is determined using this

w_{in} = c_{p} ( T2 - T1 )

where: cp ( constant pressure of helium gas ) = 5.1926 kJ/kg.K

             T2 = 576.9 k, T1 = 303 K

plugging values back into equation 3

w_{in} = 1422.3 kJ / kg

4 0
3 days ago
Other questions:
  • A. Calculate the fraction of atom sites that are vacant for lead at its melting temperature of 327°C (600 K). Assume an energy f
    5·1 answer
  • A Carnot heat engine receives heat from a reservoir at 900oC at a rate of 800 kJ/min and rejects the waste heat to the ambient a
    13·1 answer
  • A rod is 2m long at temperature of 10oC. Find the expansion of the rod, when the temperature is raised to 80oC. If this expansio
    7·1 answer
  • Current density is given in cylindrical coordinates as J = −106z1.5az A/m2 in the region 0 ≤ rho ≤ 20 µm; for rho ≥ 20 µm, J = 0
    13·1 answer
  • A long, circular aluminum rod is attached at one end to a heated wall and transfers heat by convection to a cold fluid.
    12·1 answer
  • A pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of th
    6·1 answer
  • Marble A is placed in a hollow tube, and the tube is swung in a horizontal plane causing the marble to be thrown out. As viewed
    11·1 answer
  • Consider film condensation on a vertical plate. Will the heat flux be higher at the top or at the bottom of the plate? Why?
    5·1 answer
  • A center-point bending test was performed on a 2 in. x d in. wood lumber according to ASTM D198 procedure with a span of 4 ft an
    12·1 answer
  • 4.68 Steam enters a turbine in a vapor power plant operating at steady state at 560°C, 80 bar, and exits as a saturated vapor at
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!