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
4 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]4 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
Interpret the assembly program below: MOV R3,R0;
Reika [66]

Answer:

Explanation:

1.  With the operands R0, R1, the program would compute AND operation and ADD operation .

2. The operands could truly be signed 2's complement encoded (i.e Yes) .

3. The overflow truly occurs when two numbers that are unsigned were added and the result is larger than the capacity of the register, in that situation, overflow would occur and it could corrupt the data.

 When the result of an operation is smaller in magnitude than the smallest value represented by the data type, then arithmetic underflow will occur.

7 0
4 years ago
A driver takes 3.5 s to react to a complex situation while traveling at a speed of 60 mi/h. How far does the vehicle travel befo
victus00 [196]

Answer:

x = 93.8 m.

Explanation:

During the entire the reaction time interval, the vehicle continues moving at the same speed that it was moving, i.e., 60 mi/hr.

In order to calculate the distance in meters, travelled at that speed, it is advisable first to convert the 60 mi/hr to m/seg, as follows:

60 mi/hr = 60*\frac{1hr}{3,600s}*\frac{1,605m}{1mi} = 26.8 m/s

Applying the definition of average velocity, we can solve for Δx, as follows:

Δx = 26.8 m/s* 3.5 s = 93.8 m

7 0
3 years ago
The dot plot shows the number of cupcakes bought by each person who came to a bake sale.
Maslowich

The true statement about the dot plot is 1 has 4 and 0 dots.

Explanation:

  • after creating a Bar chart 4 is the right answer.
  • The highest among st all the other plots is 1 but 4 shows 3.
  • Taking an average from all the data points 3 comes to the right answer.
  • Median the central Mid-point is 3.
  • Mode also comes to 3.
  • It is skewed on the right due to the 1st one.
  • Skewed shows the data point either increasing or in decreasing.
  • There a to Bi- histograms which has two ups and downs.
  • The true statement has to be as Mean=Median=Mode is 3.

6 0
3 years ago
(d) Arches NP is known for its spectacular arches that develop in the jointed areas of the park. Placemark Problem 2d flies you
Whitepunk [10]

Answer:

☐ NE-SW

Explanation:

Based on the description, the rock direction is North East - South West (NE-SW). Rocks generally can expand or compress depending on the type and magnitude of stress applied on the rocks. However, if the applied stress is sufficiently high, cracks and fractures will be created on the rock and it can ultimately lead to the formation of particles.

8 0
3 years ago
Determine the maximum intensity ww of the uniform distributed load that can be applied to the beam without risk of causing the s
AnnyKZ [126]

Answer:

Please see attachment

Explanation:

Please see attachment

3 0
4 years ago
Other questions:
  • When designing a car that runs on wind or Air car . can you tell me the details for the following points Compressed Air Engine:
    8·1 answer
  • Consider a process in which a carbon-based fuel is combusted in the presence of 70% excess oxygen (assume that all of the oxygen
    10·1 answer
  • Matthew wants to manufacture a large quantity of products with standardized products having less variety. Which type of producti
    5·1 answer
  • a. To measure the water current in an ocean, a marker is dropped onto it. Determine if the trajectory traced by the drifting mar
    5·1 answer
  • Question 21(Multiple Choice
    11·2 answers
  • The acceleration of a point is given. a = 20 t m/s2 When t=0, s = 50 m and v = -8 m/s. What are the position and velocity of the
    13·1 answer
  • A Styrofoam cup (k = 0.010 W/(m∙ o C)) has cross-sectional area (A) of 3.0 x 10 −2m 2 . The cup is 0.589 cm thick (L). The tempe
    12·1 answer
  • on the same scale for stress, the tensile true stress-true strain curve is higher than the engineeringstress-engineering strain
    10·1 answer
  • How the LED (light emitting diode) works?​
    8·2 answers
  • On a day in which the local atmospheric pressure is 99.5 kPa, answer each of the following: (a) Calculate the column height of m
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!