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
Rudiy27
3 years ago
12

3.24 Program: Drawing a half arrow (Java) This program outputs a downwards facing arrow composed of a rectangle and a right tria

ngle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt) (3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)

Engineering
1 answer:
eimsori [14]3 years ago
3 0

Answer:

Here is the JAVA program:

import java.util.Scanner; // to get input from user

public class DrawHalfArrow{ // start of the class half arrow

public static void main(String[] args) { // starts of main() function body

    Scanner scnr = new Scanner(System.in); //reads input

int arrowBaseHeight = 0; // stores the height of arrow base

int arrowBaseWidth  = 0; // holds width of arrow base

int arrowHeadWidth = 0; // contains the width of arrow head

// prompts the user to enter arrow base height, width and arrow head width

System.out.println("Enter arrow base height: ");

arrowBaseHeight = scnr.nextInt(); // scans and reads the input as int

System.out.println("Enter arrow base width: ");

arrowBaseWidth = scnr.nextInt();

/* while loop to continue asking user for an arrow head width until the value entered is greater than the value of arrow base width */

while (arrowHeadWidth <= arrowBaseWidth) {

    System.out.println("Enter arrow head width: ");

    arrowHeadWidth = scnr.nextInt(); }

//start of the nested loop

//outer loop iterates a number of times equal to the height of the arrow base

 for (int i = 0; i < arrowBaseHeight; i++) {

//inner loop prints the stars asterisks

      for (int j = 0; j <arrowBaseWidth; j++) {

          System.out.print("*");        } //displays stars

          System.out.println();          }

//temporary variable to hold arrowhead width value

int k = arrowHeadWidth;

//outer loop to iterate no of times equal to the height of the arrow head

for (int i = 1; i <= arrowHeadWidth; i++)

{     for(int j = k; j > 0; j--)     {//inner loop to print stars

       System.out.print("*");    } //displays stars

   k = k - 1;

   System.out.println(); } } } // continues to add more asterisks for new line

Explanation:

The program asks to enter the height of the arrow base, width of the arrow base and the width of arrow head. When asking to enter the width of the arrow head, a condition is checked that the arrow head width arrowHeadWidth should be less than or equal to width of arrow base arrowBaseWidth. The while loop keeps iterating until the user enters the arrow head width larger than the value of arrow base width.

The loop is used to output an arrow base of height arrowBaseHeight. So point (1) is satisfied.

The nested loop is being used which as a whole outputs an arrow base of width arrowBaseWidth. The inner loop draws the stars and forms the base width of the arrow, and the outer loop iterates a number of times equal to the height of the arrow. So (2) is satisfied.

A temporary variable k is used to hold the original value of arrowHeadWidth so that it keeps safe when modification is done.

The last nested loop is used to output an arrow head of width arrowHeadWidth. The inner loop forms the arrow head and prints the stars needed to form an arrow head. So (3) is satisfied.

The value of temporary variable k is decreased by 1 so the next time it enters  the nested for loop it will be one asterisk lesser.

The screenshot of output is attached.

You might be interested in
A steel bar is 150 mm square and has a hot-rolled finish. It will be used in a fully reversed bending application. Sut for the s
Xelga [282]

Answer:

See explanation

Explanation:

Given The bar is square and has a hot-rolled finish. The loading is fully reversed bending.

Tensile Strength

Sut: 600 MPa

Maximum temperature

Tmax: 500 °C

Bar side dimension

b: 150 mm

Alternating stress

σa: 100 MPa

Reliability

R: 0.999 Note 1.

Assumptions Infinite life is required and is obtainable since this ductile steel will have an endurance limit. A reliability factor of 99.9% will be used.

Solution See Excel file Ex06-01.xls.

1 Since no endurance-limit or fatigue strength information is given, we will estimate S'e based on the ultimate tensile strength using equation 6.5a.

S'e: 300 MPa = 0.5 * Sut

2 The loading is bending so the load factor from equation 6.7a is

Cload: 1

3 The part size is greater than the test specimen and the part is not round, so an equivalent diameter based on its 95% stressed area must be determined and used to find the size factor. For a rectangular section in nonrotating bending, the A95 area is defined in Figure 6-25c and the equivalent diameter is found from equation 6.7d

A95: 1125 mm2 = 0.05 * b * b Note 2.

dequiv: 121.2 mm = SQRT(A95val / 0.0766)

and the size factor is found for this equivalent diameter from equation 6.7b, to be

Csize: 0.747 = 1.189 * dequiv^-0.097

4 The surface factor is found from equation 6.7e and the data in Table 6-3 for the specified hot-rolled finish.

Table 6-3 constants

A: 57.7

b: -0.718 Note 3.

Csurf: 0.584 = Acoeff * Sut^bCoeff

5 The temperature factor is found from equation 6.7f :

Ctemp: 0.710 = 1 - 0.0058 * (Tmax - 450)

6 The reliability factor is taken from Table 6-4 for R = 0.999 and is

Creliab: 0.753

7 The corrected endurance limit Se can now be calculated from equation 6.6:

Se: 69.94 MPa = Cload * Csize * Csurf * Ctemp *

Creliab * Sprme

Let

Se: 70 MPa

8 To create the S-N diagram, we also need a value for the estimated strength Sm at 103 cycles based on equation 6.9 for bending loading.

Sm: 540 MPa = 0.9 * Sut

9 The estimated S-N diagram is shown in Figure 6-34 with the above values of Sm and Se. The expressions of the two lines are found from equations 6.10a through 6.10c assuming that Se begins at 106 cycles.

b: -0.2958 Note 4.

a: 4165.7

Plotting Sn as a function of N from equation 6.10a

N Sn (MPa)

1000 540 =aa*B73^bb

2000 440

4000 358

8000 292

16000 238

32000 194

64000 158

128000 129

256000 105

512000 85

1000000 70

FIGURE 6-34. S-N Diagram and Alternating Stress Line Showing Failure Point

10 The number of cycles of life for any alternating stress level can now be found from equation 6.10a by replacing σa for Sn.

At N = 103 cycles,

Sn3: 540 MPa = aa * 1000^bb

At N = 106 cycles,

Sn6: 70 MPa = aa * 1000000^bb

The figure above shows the intersection of the alternating stress line (σa = 100 MPa) with the failure line at N = 3.0 x 105 cycles.

8 0
3 years ago
The advantage of using rose bud tips is that they:
Jlenok [28]

Answer:

The advantage to using a rosebud tip is that it expands the flame temperature over a wider area vs using a #0 size tip.

Explanation:

Hope this helped Mark BRAINLIEST!!

3 0
2 years ago
A fatigue test was conducted in which the mean stress was 90 MPa (13050 psi), and the stress amplitude was 190 MPa (27560 psi).
Gwar [14]

Answer:

a) 280MPa

b) -100MPa

c) -0.35

d) 380 MPa

Explanation:

GIVEN DATA:

mean stress \sigma_m = 90MPa

stress amplitude \sigma_a = 190MPa

a) \sigma_m =\frac{\sigma_max+\sigma_min}{2}

    90 =\frac{\sigma_{max}+\sigma_{min}}{2} --------------1

\sigma_a =\frac{\sigma_{max}-\sigma_{min}}{2}

   190 = \frac{\sigma_{max}-\sigma_{min}}{2} -----------2

solving 1 and 2 equation we get

\sigma_{max} = 280MPa

b) \sigma_{min} = - 100MPa

c)

stress ratio=\frac{\sigma_{min}}{\sigma_{max}}

=\frac{-100}{280} = -0.35

d)magnitude of stress range

                      =(\sigma_{max} -\sigma_{min})

                       = 280 -(-100) = 380 MPa

3 0
3 years ago
I. Draw the velocity diagram for the instant shown and determine the velocity of
trapecia [35]

Answer:

?????????????????????????????????????

3 0
3 years ago
2. A
Charra [1.4K]
Answer: Projectile

Explanation:
A projectile is any object that once projected or dropped continues in motion by its own inertia and is influenced only by the downward force of gravity.
8 0
3 years ago
Other questions:
  • In this milestone we will create a Course class to represent a course and display its information on the screen. We will create
    9·1 answer
  • List irreversibilities
    11·1 answer
  • Write down a transfer function of a stable system for which pure proportional feedback could drive the system unstable.
    11·1 answer
  • A car radiator is a cross-flow heat exchanger with both fluids unmixed. Water, which has a flow rate of 0.05 kg/s, enters the ra
    15·1 answer
  • How may a Professional Engineer provide notice of licensure to clients?
    9·1 answer
  • The convection heat transfer coefficient for a clothed person standing in moving air is expressed as h 5 14.8V0.69 for 0.15 , V
    12·2 answers
  • Respond with TRUE if the symbol of the valve shown below is
    10·1 answer
  • The image shows the relative positions of Earth and the Sun for each of the four seasons. Earth travels in an elliptical orbit a
    11·2 answers
  • Which symbol should be used for the given scenario?
    11·1 answer
  • Rotating magnetic field inside a set of conducting wires is a simple description of a what
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!