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
Disc brake rotors that are too thin cannot handle as much heat and will experience ___________.
konstantin123 [22]

Answer:

brake fade

Explanation:

Among the most frequent problems in the brake disc is their overheating. When there is overheating, the temperature of the disc rises to critical values, thus the brake pad starts to slide with respect to the disc, and the efficiency of the brake system decreases to a minimum.

Overheating of the brake disc is detected when inspecting the parts. Steel is the most common base material in the creation of brake discs. When heated, the material becomes its color. A disc of steel at critical temperature, turns bright orange and later on cooling becomes purple.

If a color change is seen on the brake discs when inspecting, a service station must be contacted without delay for an in-depth examination. After detecting the problem, the brake discs and pads will be changed in a mandatory way.

6 0
3 years ago
A battery with an f.e.m. of 12 V and negligible internal resistance is connected to a resistor of 545 How much energy is dissipa
Alenkasestr [34]

Answer:

When are resistors in series? Resistors are in series whenever the flow of charge, called the current, must flow through devices sequentially. For example, if current flows through a person holding a screwdriver and into the Earth, then  

R

1

 in Figure 1(a) could be the resistance of the screwdriver’s shaft,  

R

2

 the resistance of its handle,  

R

3

 the person’s body resistance, and  

R

4

 the resistance of her shoes.

Figure 2 shows resistors in series connected to a voltage source. It seems reasonable that the total resistance is the sum of the individual resistances, considering that the current has to pass through each resistor in sequence. (This fact would be an advantage to a person wishing to avoid an electrical shock, who could reduce the current by wearing high-resistance rubber-soled shoes. It could be a disadvantage if one of the resistances were a faulty high-resistance cord to an appliance that would reduce the operating current.)

Two electrical circuits are compared. The first one has three resistors, R sub one, R sub two, and R sub three, connected in series with a voltage source V to form a closed circuit. The first circuit is equivalent to the second circuit, which has a single resistor R sub s connected to a voltage source V. Both circuits carry a current I, which starts from the positive end of the voltage source and moves in a clockwise direction around the circuit.

Figure 2. Three resistors connected in series to a battery (left) and the equivalent single or series resistance (right).

To verify that resistances in series do indeed add, let us consider the loss of electrical power, called a voltage drop, in each resistor in Figure 2.

According to Ohm’s law, the voltage drop,  

V

, across a resistor when a current flows through it is calculated using the equation  

V

=

I

R

, where  

I

 equals the current in amps (A) and  

R

 is the resistance in ohms  

(

Ω

)

. Another way to think of this is that  

V

 is the voltage necessary to make a current  

I

 flow through a resistance  

R

.

So the voltage drop across  

R

1

 is  

V

1

=

I

R

1

, that across  

R

2

 is  

V

2

=

I

R

2

, and that across  

R

3

 is  

V

3

=

I

R

3

. The sum of these voltages equals the voltage output of the source; that is,

V

=

V

1

+

V

2

+

V

3

.

 

This equation is based on the conservation of energy and conservation of charge. Electrical potential energy can be described by the equation  

P

E

=

q

V

, where  

q

 is the electric charge and  

V

 is the voltage. Thus the energy supplied by the source is  

q

V

, while that dissipated by the resistors is

q

V

1

+

q

V

2

+

q

V

3

.

Explanation:

8 0
3 years ago
Can you help me with this
Fiesta28 [93]

the function is to provide sealed combustion so that the loss of gas is minimized

6 0
2 years ago
What is Elon Musk mad about?
boyakko [2]

Answer:

Tesla CEO Elon Musk tweeted that the company's stock was too high, and it immediately dropped in value. The tweet may have violated a deal Musk made with the SEC about his tweets and Tesla. Musk also tweeted patriotic lyrics, said his girlfriend Grimes is mad at him, and noted that their child is due on Monday

6 0
3 years ago
Design a plan for ""your yard"" (no matter where you live) that will capture and utilize rainwater. You can prepare the plan in
Jlenok [28]

Answer:

Explanation:

<u><em>General Considerations</em></u>

The design of the yard will affect the natural surface and subsurface drainage pattern of a watershed or individual hillslope. Yard drainage design has as its basic objective the reduction or elimination of energy generated by flowing water. The destructive power of flowing water increases exponentially as its velocity increases. Therefore, water must not be allowed to develop sufficient volume or velocity so as to cause excessive wear along ditches, below culverts, or along exposed running surfaces, cuts, or fills.

A yard drainage system must satisfy two main criteria if it is to be effective throughout its design life:

1. It must allow for a minimum of disturbance of the natural drainage pattern.  

2.It must drain surface and subsurface water away from the roadway and dissipate it in a way that prevents excessive collection of water in unstable areas and subsequent downstream erosion

The diagram below ilustrate diffrent sturcture of yard to be consider before planing to utiliza rainwater

4 0
3 years ago
Other questions:
  • Drag each tile to the correct box.
    15·1 answer
  • Which of the following should NOT be included in an emergency kit?
    13·2 answers
  • Write a method called compFloat5 which accepts as input two doubles as an argument (parameter). Write the appropriate code to te
    9·1 answer
  • A coin placed 30.8 cm from the center of a rotating, horizontal turntable slips when its speed is 50.8 cm/s.
    12·1 answer
  • Aerospace engineers who work for certain government agencies are often required to have security clearance. Explain two reasons
    9·1 answer
  • Blank Complete the following paragraph pertaining to the popular audio file formats.
    7·2 answers
  • The use of zeroes after a decimal point are an indicator of accuracy. a)True b)- False
    7·1 answer
  • A heating system must maintain the interior of a building at TH = 20 °C when the outside temperature is TC = 2 °C. If the rate o
    10·1 answer
  • A(94,0,14) B(52,56,94) C(10,6,48) D(128,64,10)
    6·1 answer
  • Question 6
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!