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
4 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
How does the two-stroke Otto cycle differ from the four-stroke Otto cycle?
Digiron [165]

Answer:

Two stroke cycle                                               Four stroke cycle

1.Have on power stroke in one revolution.   1.have one power  

                                                                   stroke in two  revolution                                                                            

2.Complete the cycle in 2 stroke                 2.Complete the cycle in 4 stroke    

3.It have ports                                                3.It have vales

                                                                         

4.Greater requirement of cooling              4.Lesser requirement of cooling  

5.Less thermal efficiency                            5.High thermal efficiency

6.Less volumetric efficiency                       6.High volumetric efficiency    

7.Size of flywheel is less.                           7.Size of flywheel is more.

3 0
3 years ago
How much work, in Newtons, is required to lift a 20.4-kg (45lb) plate from the ground to a stand that is 1.50 meters up?
nataly862011 [7]

Answer:

Explanation:

Work, U, is equal to the force times the distance:

U = F · r

Force needed to lift the weight, is equal to the weight: F = W = m · g

so:

U = m · g · r

   = 20.4kg · 9.81 \frac{N}{kg} · 1.50m

   = 35.316 \frac{N}{m}

   = 35.316 W

4 0
2 years ago
un contenedor de 0.01m∧3 se llena con 2kg de nitrogeno a una presion de 15mpa ¿cual es la temperatura del nitrogeno?resolver uti
777dan777 [17]
Ecfñnokg pinogdf gabn Etta r
7 0
3 years ago
Pumped-storage hydroelectricity is a type of hydroelectric energy storage used by electric power systems for load balancing. The
NikAS [45]

Answer:

A) energy loss E = pgQtH

Where p = density in kg/m3

g = gravity acceleration in m/s2

Q = flow rate in m3/s

t = time taken for flow in sec

H = height of flow in m

B) power required to run pump;

P = pgQH

Explanation:

Detailed explanation and calculation is shown in the image below

5 0
3 years ago
Thin film deposition is a process where: a)-elemental, alloy, or compound thin films are deposited onto a bulk substrate! b)-Pho
marshall27 [118]

Answer:

(A) elemental, alloy, or compound thin films are deposited on to a bulk substrate

Explanation:

In film deposition there is process of depositing of material in form of thin films whose size varies between the nano meters to micrometers onto a surface. The material can be a single element a alloy or a compound.

This technology is very useful in semiconductor industries, in solar panels in CD drives etc

so from above discussion it is clear that option (a) will be the correct answer

8 0
3 years ago
Other questions:
  • Water flows down a rectangular channel that is 1.2 m wide and 1 m deep. The flow rate is 0.95 m/s. Estimate the Froude number of
    15·1 answer
  • A copper wire of original diameter .80 m exhibits a maximum tensile load/ strength at an engineering stress= 248.2 mpa. its duct
    11·1 answer
  • Q1. In electronic circuits it is not unusual to encounter currents in the microampere range. Assume a 35 μA current, due to the
    13·1 answer
  • A cylinder with a piston restrained by a linear spring contains 2 kg of carbon dioxide at 500 kPa and 400°C. It is cooled to 40°
    7·1 answer
  • Air initially at 120 psia and 500o F is expanded by an adiabatic turbine to 15 psia and 200o F. Assuming air can be treated as a
    10·1 answer
  • What are the important things to remember when arriving for an interview?
    15·1 answer
  • typedef struct bitNode { int data; struct bitNode *left; struct bstNode *right; } bstNode; int solve(bstNode* root) { if (root =
    15·1 answer
  • The Accenture team is involved in helping a client in the transformation journey using Cloud computing. How is myNav beneficial
    6·1 answer
  • What are flip flops and what do they look like
    14·2 answers
  • (a) calculate the moment at point "c", where point "c" is the square 3'' below the centroid
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!