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 100-ampere resistor bank is connected to a controller with conductor insulation rated 75°C. The resistors are not used in conj
Naily [24]

Answer:

answer

Explanation:

6 0
3 years ago
A woodcutter wishes to cause the tree trunk to fall uphill, even though the trunk is leaning downhill. With the aid of the winch
Sedbober [7]

Answer:

The correct answer will be "400.4 N". The further explanation is given below.

Explanation:

The given values are:

Mass of truck,

m = 600 kg

g = 9.8 m/s²

On equating torques at the point O,

⇒  T\times Cos(10+5)\times (1.3+4)=mg\times Sin(5)\times 4

So that,

On putting the values, we get

⇒  T\times Cos(15^{\circ})\times 5.3=600\times 9.8\times Sin(5^{\circ})\times 4

⇒                             T=400.4 \ N

8 0
3 years ago
How can I draw this image in 2D form
Ket [755]

Answer:

no it is not 2D

Explanation:

it is 3D

ok so follow these steps

- make hole

-make square

-make triangle

ok now your figure is ready

5 0
2 years ago
If you are a mechanical engineer answer these questions:
Natasha_Volkova [10]

Answer:

1. Yes, they are all necessary.

2. Both written and verbal communication skills are of the utmost importance in business, especially in engineering. Communication skills boost you or your teams' performance because they provide clear information and expectations to help manage and deliver excellent work.

3 0
3 years ago
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
3 years ago
Other questions:
  • A fluid flows steadily through a pipe with a uniform cross sectional area. The density of the fluid decreases to half its initia
    6·1 answer
  • A decorative fountain was built so that water will rise to a hieght of 8 feet above the exit of the pipe. the pipe is 3/4 diamet
    5·1 answer
  • How many kg / day of NaOH must be added to neutralize a waste stream generated by an industry producing 90,800 kg / day of sulfu
    6·2 answers
  • Write a program in C++ that can be used by a small theater to sell tickets for performances.The theater’s auditorium has 15 rows
    7·1 answer
  • What is the t max for a carbon steel heater tube?
    8·1 answer
  • A 40 mph wind is blowing past your house and speeds up as it flows up and over the roof. If the elevation effects are negligible
    14·1 answer
  • Describe three parts of a fluid power system and the roles played by each to make the device work.
    8·1 answer
  • Water enters an ice machine at 55°F and leaves as ice at 25°F. If the COP of the ice machine is 2.45 during this operation, dete
    7·1 answer
  • Convection ovens operate on the principle of inducing forced convection inside the oven chamber with a fan. A small cake is to b
    6·1 answer
  • The 5 ft wide gate ABC is hinged at C and contacts a smooth surface at A. If the specific weight of the water is 62.4 lb/ft3 , f
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!