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
Describe the make-up of an internal combustion engine.<br> Pls answer quickly.
Whitepunk [10]

Answer:

The engine consists of a fixed cylinder and a moving piston. The expanding combustion gases push the piston, which in turn rotates the crankshaft. Ultimately, through a system of gears in the power-train, this motion drives the vehicle's wheels.

Explanation:

8 0
2 years ago
Shear strain can be expressed in units of either degrees or radians. a)True b)- False
ExtremeBDS [4]

Answer:

true

Explanation:

shear strain is define as the ratio of change in deformation to the original length perpendicular to the axes of member due to shear stress.

     ε    = deformation/original length

         

strain is a unit less quantity but shear stain is generally expressed in radians but it can also be expressed in degree.

3 0
3 years ago
Two gases—neon and air—are expanded from P1 to P2 in a closed-system polytropic process with n = 1.2. _____ produces more work w
Makovka662 [10]

Answer:

Note that Air requires lesser work

Explanation:

Calculate  for general work done

SInce Gas constant 'R' for:  Neon = 0.4119KJ/kg.k , and Air = 0.287 kJ/kg·K

Calculate for work done of NEON

Calculate for work done of Air

See solution attached.

7 0
2 years ago
An interrupted line of sight means changes in ......and .... are necessary for re-establishing a ......... to the driver’s path
Mrrafil [7]

Answer:

Welcome to Gboard clipboard, any text that you copy will be saved here.

Explanation:

Touch and hold a clip to pin it. Unpinned clips will be deleted after 1 hour.

5 0
2 years ago
Which of the following sensors is used to provide suspension control module with feedback regarding vehicle cornering​ forces?
Readme [11.4K]

Answer:

A

Explanation:

4 0
2 years ago
Other questions:
  • A hanging wire made of an alloy of nickel with diameter 0.19 cm is initially 2.8 m long. When a 59 kg mass is hung from it, the
    15·1 answer
  • Which conditions are required for nuclear fusion to begin
    8·1 answer
  • Oil with a specific gravity of 0.72 is used as the indicating fluid in a manometer. If the differential pressure across the ends
    6·1 answer
  • A piston cylinder assembly fitted with a slowly rotating paddle wheel contains 0.13 kg of air at 300K. The air undergoes a const
    10·1 answer
  • The statement that is NOT true about the difference between laminar and turbulent boundary layers is:1.the Reynolds number for a
    8·1 answer
  • A resonant six-turn loop of closely spaced turns is operating at 50 MHz. The radius of the loop is λ/30, and the loop is connect
    15·1 answer
  • Make a sketch of a simple mechanically expanded brake and indicate the forces ​ ​ acting on the leading shoe when the brake is a
    10·1 answer
  • The structure of PF3(C6H5)2 is trigonal bipyramidal, with one equatorial and two axial F atoms which interchange positions when
    15·1 answer
  • An electrical layout is a drawing that indicates how the ________ of a circuit will be connected to one another and where the wi
    9·1 answer
  • What is resonance as in ultrasound waves formation using magnetostriction method​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!