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
The Danish scientist Niels Bohr proposed a model of the atom that is not totally accurate today but still contains components th
blagie [28]

Answer:

Option B

Planetary

Explanation:

In 1913, Niels Bohr proposed a model to explain the stability of orbits around the nucleus. Niels believed that light is emitted by an electron when the electron's energy changes. Bohr Atomic Model is sometimes called planetary model because it resembles a mini-solar system.

7 0
3 years ago
Establishes general guidelines concerning licensing and vehicle
gavmur [86]

Answer:

A. National Highway Safety Act

Explanation:

The National Highway Safety Act establishes general guidelines concerning licensing, vehicle registration and inspection, and traffic laws for state regulations. The act was made in 1966 to reduce the amount of death on the highway as a result of increase in deaths by 30% between 1960 and 1965

National Traffic and Motor Vehicle Safety Act regulates vehicle manufacturers  by ensuring national safety standards and issuance recalls for defective vehicles

Uniform Traffic Control Devices Act  defines shapes, colors and locations for road signs, traffic signals, and road markings

5 0
3 years ago
Read 2 more answers
How can you evaluate whether the slope of the dependent variable with an independent variable is the same for each level of the
s2008m [1.1K]

Answer:

By running multiple regression with dummy variables

Explanation:

A dummy variable is a variable that takes on the value 1 or 0. Dummy variables are also called binary

variables. Multiple regression expresses a dependent, or response, variable as a linear

function of two or more independent variables. The slope is the change in the response variable. Therefore, we have to run a multiple regression analysis when the variables are measured in the same measurement.The number of dummy variables you will need to capture a categorical variable

will be one less than the number of categories. When there is no obvious order to the categories or when there are three or more categories and differences between them are not all assumed to be equal, such variables need to be coded as dummy variables for inclusion into a regression model.

3 0
3 years ago
Since you became discouraged not being able to find a job in the San Diego area, you enlarged the area in which you looked for a
nordsb [41]

Answer:

need points 48986

Explanation:

5 0
3 years ago
An amplifier which needs a high input resistance and a high output resistance is : Select one: a. A voltage amplifier b. None of
True [87]

Answer:

None of these

Explanation:

There are different types of amplifiers, and each has different characteristics.

  • Voltage amplifier needs high input and low output  resistance.
  • Current amplifier needs Low Input and High Output  resistance.
  • Trans-conductance amplifier Low Input and High Output resistance.
  • Trans-Resistance amplifier requires High Input and Low output  resistance.

Therefore, the correct answer is "None of these "

3 0
3 years ago
Other questions:
  • Suppose that a wing component on an aircraft is fabricated from an aluminum alloy that has a plane strain fracture toughness of
    13·1 answer
  • Define the difference between elastic and plastic deformation in terms of the effect on the crystal lattice structure.
    5·1 answer
  • What would be the most likely scale factor to use for an n-gauge model train setup? (An n-gauge layout uses locomotives that are
    8·1 answer
  • What is the purpose of a heater core
    5·2 answers
  • Nguyên lý hoạt động của kim phun
    7·1 answer
  • The branding, packaging, and labeling of your product should accomplish all of the following except
    12·1 answer
  • प्रहार का समरूपी भिन्नार्थक शब्द अर्थ के साथ ​
    10·1 answer
  • When mass is the same, what is the relationship between radius and compression strength?
    5·1 answer
  • Calculate the acceleration of a 2000kg single engine airlane just before take off when the thrust of the engine is 500n?
    5·1 answer
  • Which of these processes uses a die and a press to form parts?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!