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
Determine the total condensation rate of water vapor onto the front surface of a vertical plate that is 10 mm high and 1 m in th
castortr0y [4]

Answer:

Q =  63,827.5 W

Explanation:

Given:-

- The dimensions of plate A = ( 10 mm x 1 m )

- The fluid comes at T_sat , 1 atm.

- The surface temperature, T_s = 75°C  

Find:-

Determine the total condensation rate of water vapor onto the front surface of a vertical plate

Solution:-

- Assuming drop-wise condensation the heat transfer coefficient for water is given by Griffith's empirical relation for T_sat = 100°C.

                            h = 255,310 W /m^2.K

- The rate of condensation (Q) is given by Newton's cooling law:

                           Q = h*As*( T_sat - Ts )

                           Q = (255,310)*( 0.01*1)*( 100 - 75 )

                           Q =  63,827.5 W

8 0
3 years ago
Read 2 more answers
What is the mode of operation of a ramp digital voltimeter​
liberstina [14]

Answer:

The operating principle of a ramp type digital voltmeter is to measure the time that a linear ramp voltage takes to change from level of input voltage to zero voltage (or vice versa).

7 0
1 year ago
If welding is being done in the vertical position, the torch should have a travel angle of?
siniylev [52]

Answer:

Between 35°– 45°

Explanation:

In the vertical position, Point the flame in the direction of travel. Keep the flame tip at the correct height above the base metal. An angle of 35°–45° should be maintained between the torch tip and the base metal. This angle may be varied up or down to heat or cool the weld pool if it is too narrow or too wide

4 0
2 years ago
Burn rate can be affected by: A. Variations in chamber pressure B. Variations in initial grain temperature C. Gas flow velocity
Digiron [165]

Answer: D) All of the above

Explanation:

Burn rate can be affected by all of the above reasons as, variation in chamber pressure because the pressure are dependence on the burn rate and temperature variation in initial gain can affect the rate of the chemical reactions and initial gain in the temperature increased the burning rate. As, gas flow velocity also influenced to increasing the burn rate as it flowing parallel to the surface burning. Burn rate is also known as erosive burning because of the variation in flow velocity and chamber pressure.

4 0
3 years ago
Which of the following is not a relationship set between elements in a sketch​
Svet_ta [14]

Answer:

The entity relationship (ER) data model has existed for over 35 years. It is well suited to data modelling for use with databases because it is fairly abstract and is easy to discuss and explain. ER models are readily translated to relations. ER models, also called an ER schema, are represented by ER diagrams.

6 0
2 years ago
Other questions:
  • To be able to write an ss-domain equation for a circuit, use partial fraction decomposition to separate the terms in this equati
    12·1 answer
  • An air-standard Otto cycle has a compression ratio of 6 and the temperature and pressure at the beginning of the compression pro
    13·1 answer
  • If a steel cable is rated to take 800-lb and the steel has a yield strength of 90,000psi, what is the diameter of the cable?
    12·1 answer
  • You have designed a bone plate that is manufactured via rolling under cold working conditions, and tests show good biocompatibil
    14·1 answer
  • The rolling process is governed by the frictional force between the rollers and the workpiece. The frictional force at the entra
    5·1 answer
  • Assume a steel pipe of inner radius r1= 20 mm and outer radius r2= 25 mm, which is exposed to natural convection at h = 50 W/m2.
    12·1 answer
  • An object at a vertical elevation of 20 m and a speed of 5 m/s decreases in elevation to an elevation of 1 m. At this location,
    15·1 answer
  • A force is a push or pull in? A.a circle B.an arc C.a straight line
    5·1 answer
  • It is ___ for motorcyclists to ride more than two abreast in a lane.
    7·1 answer
  • You insert a dielectric into an air-filled capacitor. How does this affect the energy stored in the capacitor?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!