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
T
solniwko [45]

Answer:

Common Uses: Boxwood is well-suited for carving and turning, and the tree's diminutive size restricts it to smaller projects. Some common uses for Boxwood include: carvings, chess pieces, musical instruments (flutes, recorders, woodwinds, etc.), rulers, handles, turned objects, and other small specialty items.If you want a small, compact, low-growing shrub to form a hedge that serves as an accent or border along your walkway, fence line or planting beds, dwarf boxwood varieties are the best pick. The "Dwarf English" boxwood (Buxus sempervirens “Suffruticosa”) creates a border hedge approximately 1 to 2 feet in height.

Explanation:

3 0
3 years ago
The lattice constant of a simple cubic primitive cell is 5.28 Å. Determine the distancebetween the nearest parallel ( a ) (100),
skelet666 [1.2K]

Answer:

a)5.28 Å , b)3.73 Å , c)3.048 Å

Explanation:

the atoms are situated only at the corners of cube.Each and every atom in simple cubic primitive at the corner is shared with 8 adjacent unit cells.

Therefore, a particular unit cell consist only 1/8th part of an atom.

The lattice constant of a simple cubic primitive cell is 5.28 Å

We know formula of distance,

d = \frac{a}{\sqrt{h^{2}+k^{2}+l^{2}}}

a)(100)

a=5.28 Å

Distance = \frac{5.28 Å}{\sqrt{1^{2}+0^{2}+0^{2}}}=5.28 Å

b)(110)

Distance = \frac{5.28}{\sqrt{1^{2}+1^{2}+0^{2}}} = 3.73 Å

c)(111)

Distance= \frac{5.28}{\sqrt{1^{2}+1^{2}+1^{2}}}= 3.048 Å

6 0
3 years ago
A block of ice weighing 20 lb is taken from the freezer where it was stored at -15"F. How many Btu of heat will be required to c
Rus_ich [418]

Answer:

Heat required =7126.58 Btu.

Explanation:

Given that

Mass m=20 lb

We know that

1 lb =0.45 kg

So 20 lb=9 kg

m=9 kg

Ice at -15° F and we have to covert it at 200° F.

First ice will take sensible heat at up to 32 F then it will take latent heat at constant temperature and temperature will remain 32 F.After that it will convert in water and water will take sensible heat and reach at 200 F.

We know that

Specific heat for ice C_p=2.03\ KJ/kg.K

Latent heat for ice H=336 KJ/kg

Specific heat for ice C_p=4.187\ KJ/kg.K

We know that sensible heat given as

Q=mC_p\Delta T

Heat for -15F to 32 F:

Q=mC_p\Delta T

Q=9\times 2.03(32+15) KJ

Q=858.69 KJ

Heat for 32 Fto 200 F:

Q=mC_p\Delta T

Q=9\times 4.187(200-32) KJ

Q=6330.74 KJ

Total heat=858.69 + 336 +6330.74 KJ

Total heat=7525.43 KJ

We know that 1 KJ=0.947 Btu

So   7525.43 KJ=7126.58 Btu

So heat required to covert ice into water is 7126.58 Btu.

8 0
3 years ago
Steam enters an adiabatic turbine at 8 MPa and 500C with a mass flow rate of 3
Vinil7 [7]

Answer:

a)temperature=69.1C

b)3054Kw

Explanation:

Hello!

To solve this problem follow the steps below, the complete procedure is in the attached image

1. draw a complete outline of the problem

2. to find the temperature at the turbine exit  use termodinamic tables to find the saturation temperature at 30kPa

note=Through laboratory tests, thermodynamic tables were developed, these allow to know all the thermodynamic properties of a substance (entropy, enthalpy, pressure, specific volume, internal energy etc ..)  

through prior knowledge of two other properties such as pressure and temperature.  

3. Using thermodynamic tables find the enthalpy and entropy at the turbine inlet, then find the ideal enthalpy using the entropy of state 1 and the outlet pressure = 30kPa

4. The efficiency of the turbine is defined as the ratio between the real power and the ideal power, with this we find the real enthalpy.

Note: Remember that for a turbine with a single input and output, the power is calculated as the product of the mass flow and the difference in enthalpies.

5. Find the real power of the turbine

3 0
3 years ago
On a piece of paper, sketch the x-y stress state and the properly oriented principal stress state. Use the resulting sketch to a
stealth61 [152]

Answer:

See explaination

Explanation:

Please kindly check attachment for the step by step and very detailed solution of the given problem

6 0
3 years ago
Other questions:
  • Laws that protect businesses involve
    10·1 answer
  • (8 points) Consider casting a concrete driveway 40 feet long, 12 feet wide and 6 in. thick. The proportions of the mix by weight
    8·1 answer
  • A socket can be driven using any of the following except for (A) a socket ratchet
    14·1 answer
  • Calculate the equivalent capacitance of the three series capacitors in Figure 12-1 A) 0.060 uF B) 0.8 uF C) 0.58 uF D) 0.01 uF
    12·1 answer
  • Which of the following justifies the need for an already-certified engineer to continue to take classes?
    15·1 answer
  • If you have a hole diameter of 0.250 with a tolerance of ±0.005, what are the limits of the hole size?
    13·1 answer
  • Trees grow in bulk in outward direction​
    9·1 answer
  • . Bơm kiểu piston tác dụng đơn có áp suất p=0,64 Mpa và lưu lượng Q=3,5 l/s. Xác định tốc độ quay của trục bơm và công suất của
    7·1 answer
  • Lance is the sitting judge in the local family court. What education might have been
    10·1 answer
  • A logic circuit with 3 gates and 2 inputs. The circuit will be read from the final output to the inputs.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!