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
Because of ____________ people must make choices, and when they choose, they incur a(n)______________.
lbvjy [14]
There must be a photo for me to answer!
3 0
3 years ago
What should you consider when choosing the type of head protection
Serggg [28]

Answer: hope this helps u

Explanation:

Material,Flexibility,Comfort,Workplace Hazards

6 0
2 years ago
As project manager, you approve a team member’s request to change the order of their tasks because they think it will be more ef
Oduvanchick [21]

The project is going to scope if the situation happens. Option A is correct.

<h3 /><h3>What is the function of a project manager?</h3>

Project managers are in charge of organizing, planning, and guiding the execution of certain projects for an organization .

As the project manager, you grant a team member's request to rearrange their work in a way they believe will increase productivity.

However, this modification interferes with another team member's workflow since they now have to complete two more activities that are unrelated to the project's objective. The project will be within its scope.

Hence option A is correct.

To learn more about the project manager refer;

brainly.com/question/15404120

#SPJ1

6 0
2 years ago
HELPP!!! Calculating voltage drop
kifflom [539]

Answer:

srry

Explanation:

5 0
3 years ago
The insulation resistance of a motor operated by an electronic drive is to be tested using a megger. What precaution should you
EleoNora [17]
Use protective gear. Use insulated tools, Wear flame resistant clothing, safety glasses, and insulation gloves, Remove watches or other jewelry, Stand on an insulation mat. 03. Never connect the insulation tester to energized conductors or energized equipment and always follow the manufacturer's recommendations. When installing new electrical machinery or equipment, testing insulation resistance is important for two reasons. First, it ensures that the insulation is in adequate condition to begin operation. ... The test is accomplished by applying DC voltage through the de-energized circuit using an insulation tester. Insulation resistance should be approximately one megohm for each 1,000 volts of operating voltage, with a minimum value of one megohm. For example, a motor rated at 2,400 volts should have a minimum insulation resistance of 2.4 megohms.
4 0
3 years ago
Other questions:
  • In the combination of resistors above, consider the 1.50 µΩ and 0.75 µΩ. How can you classify the connection between these two r
    6·1 answer
  • Three tool materials (high-speed steel, cemented carbide, and ceramic) are to be compared for the same turning operation on a ba
    10·1 answer
  • If you were choosing between two strain gauges, one which has a single resistor in a bridge that varies and one that has two res
    11·1 answer
  • An actual vapour compression system comprises following process represents a. 1-2 Compression process b. 2-3 Condens 1 (or heat
    5·1 answer
  • Consider a modification of the air-standard Otto cycle in which the isentropic compression and expansion processes are each repl
    10·1 answer
  • The cube measures 3.0-ft on all sides and has a density of 3.1 slugs/ft3. How much does it weigh?
    7·1 answer
  • Saturated liquid water at 150 F is put under pressure to decrease the volume by 1% while keeping the temperature constant. To wh
    8·1 answer
  • Please help I need it by today!!!
    10·1 answer
  • 1. Springs____________<br> energy when compressed<br> And _________energy when they rebound.
    12·1 answer
  • A gas tank is known to have a thickness of 0.5 inches and an internal pressure of 2.2 ksi. Assuming that the maximum allowable s
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!