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 is the connection between the air fuel ratio and an engine running rich/poor? please give clear examples and full sentances
gavmur [86]

Explanation:

Air fuel ratio:

 Air fuel ratio is the ratio of mass of air to the mass of fuel.So we can say that

Air\ fuel\ ratio=\dfrac{mass\ of\ air}{mass\ of\ fuel}

As we know that fuel burn in the presence of air that is why we have to maintain a proper amount of air fuel ratio.

When we need more power then we have supply more fuel and to burn this fuel ,require a specified amount of air.So for different loading condition of engine different air fuel ratio is required.

When air is less and fuel is more then it is called rich air fuel ratio .when air is more and fuel is less then it is called poor air fuel ratio.

5 0
4 years ago
Find the total present worth of a series of cash flows with an annual interest rate of 2% per year. Round your answer to the nea
prisoha [69]

The total present worth is $19,783.01

The present worth of a series of cash flow is the value of the cash flows in year 0 (today)

Cash flow in year 0 = 5330

Cash flow in year 1 = 0

Cash flow in year 2 = 0

Cash flow in year 3 = 13075 / (1.02)^3 = 12,320.86

Cash flow in year 4 = 2308 / (1.02)^4 = 2,132.24

Present worth = $19,783.01

A similar question was solved here: brainly.com/question/9641711?referrer=searchResults

5 0
3 years ago
Explain the conductivity results observed for ionic compounds in the solid state and in aqueous solution.i.Solid ionic compounds
Svetach [21]

Answer:

Aqueous solution of ionic compounds conduct electricity while solid ionic compounds don't.

Explanation:

Ionic compound conduct electricity when liquid or in aqueous solution that is resolved in water because the ionic bonds of the compound become weak and the ions are free to move from place to place.

Ionic compounds don't conduct electricity while in solid state because the ionic bonds are to strong and ions cannot move around with lack of space for movement which makes the electric conductivity zero.

8 0
3 years ago
Can someone tell me what car year and model this is please
Arlecino [84]

Answer:

i think 1844

Explanation:

5 0
3 years ago
Read 2 more answers
A rich industrialist was found murdered in his house. The police arrived at the scene at 11:00 PM. The temperature of the corpse
d1i1m1o1n [39]

Answer:

The dude was killed around 6:30PM

Explanation:

Newton's law of cooling states:

    T = T_m + (T_0-T_m)e^{kt}

where,

T_0 = initial temp

T_m = temp of room

T = temp after t hours

k = how fast the temp is changing

t = time (hours)

T_0 = 31     because the body was initlally 31ºC when the police found it

T_m = 22   because that was the room temp

T = 30  because the body temp drop to 30ºC after 1 hour

t = 1 because that's the time it took for the body temp to drop to 30ºC

k=???   we don't know k so we must solve for this

rearrange the equation to solve for k

T = T_m + (T_0-T_m)e^{kt}

T - T_m= (T_0-T_m)e^{kt}

\frac{T - T_m}{(T_0-T_m)}= e^{kt}

ln(\frac{T - T_m}{T_0-T_m})=kt

\frac{ln(\frac{T - T_m}{T_0-T_m})}{t}=k

plug in the numbers to solve for k

k = \frac{ln(\frac{T - T_m}{T_0-T_m})}{t}

k = \frac{ln(\frac{30 - 22}{31-22})}{1}

k=ln(\frac{8}{9})

Now that we know the value for k, we can find the moment the murder occur. A crucial information that the question left out is the temperature of a human body when they're still alive. A living human body is about 37ºC. We can use that as out initial temperature to solve this problem because we can assume that the freshly killed body will be around 37ºC.

T_0 = 37     because the body was 37ºC right after being killed

T_m = 22   because that was the room temp

T = 31  because the body temp when the police found it

k=ln(\frac{8}{9})   we solved this earlier

t = ???   we don't know how long it took from the time of the murder to when the police found the body

Rearrange the equation to solve for t

T = T_m + (T_0-T_m)e^{kt}

T - T_m= (T_0-T_m)e^{kt}

\frac{T - T_m}{(T_0-T_m)}= e^{kt}

ln(\frac{T - T_m}{T_0-T_m})=kt

\frac{ln(\frac{T - T_m}{T_0-T_m})}{k}=t

plug in the values

t=\frac{ln(\frac{T - T_m}{T_0-T_m})}{k}

t=\frac{ln(\frac{31 - 22}{37-22})}{ln(8/9)}

t=\frac{ln(3/5)}{ln(8/9)}

t=\frac{ln(3/5)}{ln(8/9)}

t ≈ 4.337 hours from the time the body was killed to when the police found it.

The police found the body at 11:00PM so subtract 4.337 from that.

11 - 4.33 = 6.66 ≈ 6:30PM

7 0
3 years ago
Other questions:
  • A petrol engine produces 20 hp using 35 kW of heat transfer from burning fuel. What is its thermal efficiency, and how much powe
    14·1 answer
  • Explain the differences between 1- Energy 2- Power 3- Work 4- Heat Your answer should explain the mathematica and physical meani
    5·1 answer
  • Anyone have any good ways of revisiting <br> Or <br> Have any good study notes
    11·1 answer
  • A company specification calls for a steel component to have a minimum tensile strength of 1240 MPa. Tension tests are conducted
    7·1 answer
  • Why is it reasonable to say that no system is 100% efficient?​
    6·1 answer
  • One of the basic requirements of a servomotor is that it must produce high torque at all: a)Frequencies b)-Voltages c)-Loads d)-
    14·1 answer
  • This is a blueprint drawing of the stage area at Millennium Park. The length of one square on the grid is equal to 5 feet. Accor
    14·1 answer
  • Add my sc please?.<br><br> kindacracked
    12·2 answers
  • : A cyclical load of 1500 lb is to be exerted at the end of a 10 in. long aluminium beam (see Figure below). The bar must surviv
    6·1 answer
  • What are the BENEFITS and RISKS of using automobiles?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!