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
A ballistic pendulum consists of a 3.60 kg wooden block on the end of a long string. From the pivot point to the center‐of‐mass
Pavel [41]

Answer:

17.799°

Explanation:

When the bullet hits the block at that time the momentum is conserved

So, initial momentum = final momentum

P_i=P_f

So 28\times 10^{-3}\times 210=(3.6+0.028)v_f

v_f=1.6207\ m/sec

Now energy is also conserved

So \frac{1}{2}\times (3.6+0.028)\times 1.6207^2=(3.6+0.028)\times 9.81\times 2.8(1-cos\Theta )

cos\Theta =0.8521So\ \Theta =17.799^{\circ}

3 0
3 years ago
In the planning process of the product development life cycle what is it important to inventory
Verizon [17]

Your Answer would be A I believe.

6 0
3 years ago
A 15-ft beam weighing 570 lb is lowered by means of two cables unwinding from overhead cranes. As the beam approaches the ground
7nadin3 [17]

Answer:

I. Tension (cable A) ≈ 6939 lbf

II. Tension (cable B) ≈ 17199 lbf

Explanation:

Let's begin by listing out the data that we were given:

mass of beam (m) = 570 lb, deceleration (cable A) = -20 ft/s², deceleration (cable B) = -2 ft/s²,

g = 32.17405 ft/s²

The tension on an object is given by the product of mass of the object by gravitational force plus/minus the product of mass by acceleration.

Mathematically represented thus:

T = mg + ma

where:

T = tension, m = mass, g = gravitational force,

a = acceleration

I. For Cable A, we have:

T = mg + ma = (570 * 32.17405) + [570 * (-20)]

T = 18339.2085 - 11400 = 6939.2085

T ≈ 6939 lbf

II. For Cable B, we have:

T = mg + ma = (570 * 32.17405) + [570 * (-2)]

T = 18339.2085 - 1140 = 17199.2085

T ≈ 17199 lbf

4 0
4 years ago
Give two causes that can result in surface cracking on extruded products.
Andreas93 [3]

Answer:

1. High friction

2. High extrusion temperature

Explanation:

Surface cracking on extruded products are defects or breakage on the surface of the extruded parts. Such cracks are inter granular.

           Surface cracking defects arises from very high work piece temperature that develops cracks on the surface of the work piece. Surface cracking appears when the extrusion speed is very high, that results in high strain rates and generates heat.

          Other factors include very high friction that contributes to surface cracking an d chilling of the surface of high temperature billets.

6 0
3 years ago
A(n) is a detailed, structured diagram or drawing.
monitta

Answer:

Schematics

Explanation:

A schematic is a detailed structured diagram or drawing. It employs illustrations to help the viewer understand detailed information on the machine or object being described. Its main aim is not to help the observer know what the object looks like physically. It is rather aimed at helping the viewer know how the machine works. This is achieved by only including key and important details to the drawing.

It is most times used in the blueprint and user guides of machines and gadgets used in the home to help users know how these things work so that they can do little fixings should there be such needs.

6 0
3 years ago
Other questions:
  • Write down one metal or alloy that is best suited for each of the following applications:
    8·1 answer
  • Tech A says that a gear set that has a drive gear with 9 teeth and a driven gear with 27 teeth has a gear ratio of 3:1. Tech B s
    7·1 answer
  • The engine of a 2000kg car has a power rating of 75kW. How long would it take (seconds) to accelerate from rest to 100 km/hr at
    10·1 answer
  • A composite wall is made of two layers of 0.3 m and 0.15 m thickness with surfaces held at 600°C and 20°C respectively. If the c
    9·1 answer
  • A torsional pendulum consists of a 5 kg uniform disk with a diameter of 50 cm attached at its center to a rod 1.5 m in length. T
    13·1 answer
  • For a bronze alloy, the stress at which plastic deformation begins is 266 MPa and the modulus of elasticity is105 GPa.
    15·1 answer
  • A 2.0-in-thick slab is 10.0 in wide and 12.0 ft long. Thickness is to be reduced in three steps in a hot rolling operation. Each
    9·1 answer
  • NO SCAMS
    9·2 answers
  • ​please how to drawing mechanical drawing after connecting the all parts thanks
    6·1 answer
  • Read the passage.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!