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 are flip flops and what do they look like
Vinil7 [7]
flip flops are shoes and they look like shoes
4 0
2 years ago
Read 2 more answers
The coolant heat storage system:
Monica [59]

Answer:

c

Explanation:

This is because many things, such as pcs, over heat

8 0
3 years ago
An aircraft is in a steady level turn at a flight speed of 200 ft/s and a turn rate about the local vertical of 5 deg/s. Thrust
notka56 [123]

Answer:

L= 50000 lb

D = 5000 lb

Explanation:

To maintain a level flight the lift must equal the weight in magnitude.

We know the weight is of 50000 lb, so the lift must be the same.

L = W = 50000 lb

The L/D ratio is 10 so

10 = L/D

D = L/10

D = 50000/10 = 5000 lb

To maintain steady speed the thrust must equal the drag, so

T = D = 5000 lb

5 0
3 years ago
16 . You are turning onto a two-lane road divided by a broken yellow line. You know immediately that:
Over [174]

When a person is turning onto a two-lane road divided by a broken yellow line, you know immediately that you are on a two-way road.

<h3>What is the road about?</h3>

Note that a Yellow centerlines can be seen in roads and it is one that is often used to separate traffic moving in different directions.

Note also that Broken lines can be crossed to allow slower-moving traffic and as such, When a person is turning onto a two-lane road divided by a broken yellow line, you know immediately that you are on a two-way road.

See full question below

You are turning onto a two-lane road divided by a broken yellow line. You know immediately that:

Answers

You are on a two-way road.

You are on a one-way road.

The road is under repair.

You must stay to the left of the broken yellow lines.

Learn more about  two-way road from

brainly.com/question/13123201

#SPJ2

5 0
1 year ago
Anaircraft component is fabricated from an aluminum alloy that has a plane-strain fracture toughness of 40 MPa 1/2.It has been d
navik [9.2K]

Answer:

Yes, fracture will occur since toughness (42.4 MPa) is greater than the toughness of the material, 40MPa

Explanation:

Given

Toughness, k = 40Mpa

Stress, σ = 300Mpa

Length, l = 4mm = 4 * 10^-3m

Under which fracture occurred (i.e., σ= 300 MPa and 2a= 4.0 mm), first we solve for parameter Y (The dimensionless parameter)

Y = k/(σπ√a)

Where a = ½ of the length in metres

Y = 40/(300 * π * √(4/2 * 10^-3))

Y = 1.68 ---- Approximated

To check if fracture will occur of not; we apply the same formula.

Y = k/(σπ√a)

Then we solve for k, where

σ = 260Mpa and a = ½ * 6 * 10^-3

So,.we have

1.68 = k/(260 * π * √(6*10^-3)/2)

k = 1.68 * (260 * π * (6*10^-3)/2)

k = 42.4 MPa --- Approximately

Therefore, fracture will occur since toughness (42.4 MPa) is greater than the toughness of the material, 40 MPa

7 0
3 years ago
Read 2 more answers
Other questions:
  • Why is it a good idea to lock your doors while driving?<br> WRITER
    10·1 answer
  • Do you understand entropy? Why the concept of entropy is difficult to engineering students?
    11·1 answer
  • Refrigerant 134a enters a horizontal pipe operating at steady state at 40oC, 300 kPaand a velocity of 40 m/s. At the exit, the t
    13·1 answer
  • Kim is working on the cost estimate and feasible design options for a building. Which stage of a construction plan is Kim workin
    5·1 answer
  • (4 points) What field of work generally requires (a) an engineer to have a Professional Engineer
    11·1 answer
  • How many times has the ITU-R revised the CCIR 601 international standard? A. four B. five C. six D. seven
    8·1 answer
  • I want to know if anyone else know how to tell apart real leather from fake leather?!?!
    6·2 answers
  • Who has the authority to declare a "global emergency"?​
    10·2 answers
  • How many and what type of<br> receptacles are connected to<br> this circuit?
    15·1 answer
  • 11. As __and___ prices continued to rise in the late 1960’s and 70's, 4 and 6 cylinder engines began to make a comeback.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!