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 coal-burning power plant generates electrical power at a rate of 650 megawatts (MW), or 6.50 × 108 J/s. The plant has an overa
Vinvika [58]

Answer:

Energy produce in one year =20.49 x 10¹⁶ J/year

Explanation:

Given that

Plant produce 6.50 × 10⁸ J/s of energy.

It produce  6.50 × 10⁸ J in 1 s.

We know that

1 year = 365 days

1 days = 24 hr

1 hr = 3600 s

1 year = 365 x 24 x 3600 s

1 year = 31536000 s

So energy produce in 1 year = 31536000 x  6.50 × 10⁸ J/year

          Energy produce in one year = 204984 x 10¹² J/year

          Energy produce in one year =20.49 x 10¹⁶ J/year

7 0
3 years ago
A sleeve made of SAE 4150 annealed steel has a nominal inside diameter of 3.0 inches and an outside diameter of 4.0 inches. It i
irga5000 [103]

Answer:

Class of fit:

Interference (Medium Drive Force Fits constitute a special type of Interference Fits and these are the tightest fits where accuracy is important).

Here minimum shaft diameter will be greater than the maximum hole diameter.

Medium Drive Force Fits are FN 2 Fits.

As per standard ANSI B4.1 :

Desired Tolerance: FN 2

Tolerance TZone: H7S6

Max Shaft Diameter: 3.0029

Min Shaft Diameter: 3.0022

Max Hole Diameter:3.0012

Min Hole Diameter: 3.0000

Max Interference: 0.0029

Min Interference: 0.0010

Stress in the shaft and sleeve can be considered as the compressive stress which can be determined using load/interference area.

Design is acceptable If compressive stress induced due to selected dimensions and load is less than compressive strength of the material.

Explanation:

4 0
3 years ago
Read 2 more answers
Think about how could you design, build, and test a light maze. What specific behavior of light will be essential to the success
Mrac [35]

Answer:

Reflection

Explanation:

The specific behavior of light that will be essential to ensure the success of your design is "Reflection". This is because light maze makes use of a mirror and it's the light that is reflected that we see with our eyes. Also, the manner in which light is reflected off objects will affect the colors that are reflected as well.

4 0
3 years ago
Four race cars are traveling on a 2.5-mile tri-oval track. The four cars are traveling at constant speeds of 195 mi/h, 190 mi/h,
Snezhnost [94]

Answer:

Explanation:

1) The number of times, the car with the speed of  195 mph will cross the given point is equal to 30 minutes divided by the time taken by car to cross the 2.5 miles.

0 .5*195/2.5 = 39

Likewise, the car with the speed of 190 mph crosses the point 38 times; the car with the speed of 185 mph crosses the point 37 times

and car with the speed of 180 mph crosses it 36 times

here, the time-mean speed, vt is given below,

vt = (39*195 +38*190+37*185+36*180)/(39+38+37+38)

= 186.433 mph

and space mean speed is given by,

= (39+38+37+36)/(39/195+38/190+37/1850+36/180)

1) The number of times, the car with the speed of  195 mph will cross the given point is equal to 30 minutes divided by the time taken by car to cross the 2.5 miles.

0 .5*195/2.5 = 39

Likewise, the car with the speed of 190 mph crosses the point 38 times; the car with the speed of 185 mph crosses the point 37 times

and car with the speed of 180 mph crosses it 36 times

here, the time-mean speed, vt is given below,

vt = (39*195 +38*190+37*185+36*180)/(39+38+37+38)

= 186.433 mph

and space mean speed is given by,

= (39+38+37+36)/(39/195+38/190+37/1850+36/180)

=187.5 mph

2)  There would be only four number of observations when the aerial photo is given, therefore time mean speed, vt in that condition will be calculated as

Vt = 195+190+185+180/4

  = 187.5

Vs= 4/(1/195+1/190+1/185+1/180)

= 188.36 mph

2)  There would be only four number of observations when the aerial photo is given, therefore time mean speed, vt, in that condition will be calculated as

Vt = 195+190+185+180/4

  = 187.5

Vs= 4/(1/195+1/190+1/185+1/180)

= 188.36 mph

4 0
3 years ago
Find the following for an input of 120 VAC(RMS), 60 hertz, given a 10:1 stepdown transformer, and a full-wave bridge rectifier.
atroni [7]

Answer:

(i) 169.68 volt

(ii) 16.90 volt

(iii) 16.90 volt

(iv) 108.07 volt

(v) 2.161 A

Explanation:

Turn ratio is given as 10:1

We have given that input voltage v_p=120volt

(i) We know that peak voltage is give by v_{peak}=\sqrt{2}v_p=\sqrt{2}\times 120=169.68volt

(ii) We know that for transformer \frac{v_p}{v_s}=\frac{n_p}{n_s}

So \frac{169.08}{v_s}=\frac{10}{1}

v_s=16.90volt

So peak voltage in secondary will be 16.90 volt

(iii) Peak voltage of the rectifier will be equal to the peak voltage of the secondary

So peak voltage of the rectifier will be 16.90 volt

(iv) Dc voltage of the rectifier is given by v_{dc}=\frac{2v_m}{\pi }=\frac{2\times 1.414\times 120}{3.14}=108.07volt

(v) Now dc current is given by i_{dc}=\frac{v_{dc}}{R}=\frac{108.07}{50}=2.1614A

4 0
3 years ago
Other questions:
  • 10. What does a profile of a river from its headwaters to its mouth typically show?
    13·1 answer
  • A Transmission Control Protocol (TCP) connection is in working order and both sides can send each other data. What is the TCP so
    7·1 answer
  • The two boxcars A and B have a weight of 20000lb and 30000lb respectively. If they coast freely down the incline when the brakes
    11·1 answer
  • ________ is the most theoretical computing discipline, focusing mostly on finding new and better ways for computers to work
    9·1 answer
  • Which type of load is not resisted by a pinned joint? A) Moment B) Shear C) Axial D) Compression
    7·1 answer
  • I am sending an email to my teacher. Is this mature enough?
    15·2 answers
  • The ruler game, HELPPPP PLS
    11·2 answers
  • Computer system analyst advantage​
    5·2 answers
  • What were some of the challenges to safety resulting from such radical airframe designs as highly swept wings, high wing loading
    15·1 answer
  • A pipe fitter would fabricate which one of the following systems?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!