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]4 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 particular motor rotates at 3000 revolutions per minute (rpm). What is its speed in rad/sec, and how many seconds does it take
raketka [301]

Answer:

ω=314.15 rad/s.

0.02 s.

Explanation:

Given that

Motor speed ,N= 3000 revolutions per minute

N= 3000 RPM

The speed of the motor in rad/s given as

Now by putting the values in the above equation

ω=314.15 rad/s

Therefore the speed in rad/s will be 314.15 rad/s.

The speed in rev/sec given as

ω= 50 rev/s

It take 1 sec to cover 50 revolutions

That is why to cover 1 revolution it take

\dfrac{1}{50}=0.02\ s

5 0
4 years ago
Read 2 more answers
A horizontal curve on a two-lane road is designed with a 2,300-ft radius, 12-ft lanes, and a 65-mph design speed. Determine the
Ierofanga [76]

Answer:

distance = 22.57 ft

superelevation rate = 2%

Explanation:

given data

radius = 2,300-ft

lanes width = 12-ft

no of lane = 2

design speed = 65-mph

solution

we get here sufficient sight distance SSD that is express as

SSD = 1.47 ut + \frac{u^2}{30(\frac{a}{g}\pm G)}     ..............1

here u is speed and t is reaction time i.e 2.5 second and a is here deceleration rate i.e 11.2 ft/s² and g is gravitational force i.e 32.2 ft/s² and G is gradient i.e 0 here

so put here value and we get

SSD = 1.47 × 65 ×2.5  + \frac{65^2}{30(\frac{11.2}{32.2}\pm 0)}

solve it we get

SSD = 644 ft  

so here minimum distance clear from the inside edge of the inside lane is

Ms = Rv ( 1  - cos (\frac{28.65 SSD}{Rv}) )        .....................2

here Rv is = R - one lane width

Rv = 2300 - 6 = 2294 ft

put value in equation 2 we get

Ms = 2294 ( 1  - cos (\frac{28.65 \times 664}{2294})  )  

solve it we get

Ms = 22.57 ft

and

superelevation rate for the curve will be here as

R  = \frac{u^2}{15(e+f)}  ..................3

here f is coefficient of friction that is 0.10

put here value and we get e

2300 = \frac{65^2}{15(e+0.10)}

solve it we get

e = 2%

3 0
3 years ago
Problem Statement: Air flows at a rate of 0.1 kg/s through a device as shown below. The pressure and temperature of the air at l
Tema [17]

Answer:

The answer is "+9.05 kw"

Explanation:

In the given question some information is missing which can be given in the following attachment.

The solution to this question can be defined as follows:

let assume that flow is from 1 to 2 then

Q= 1kw

m=0.1 kg/s

From the steady flow energy equation is:

m\{n_1+ \frac{v^2_1}{z}+ gz_1 \}+Q= m \{h_2+ \frac{v^2_2}{2}+ gz_2\}+w\\\\\ change \ energy\\\\0.1[1.005 \times 800]-1= 0.01[1.005\times 700]+w\\\\w= +9.05 \ kw\\\\

If the sign of the work performed is positive, it means the work is done on the surrounding so, that the expected direction of the flow is right.

8 0
3 years ago
What position would be the lowest paid in a technology company?
murzikaleks [220]
I think the answers is b
3 0
3 years ago
11. What are restrictions when building or completing a challenge?
katrin [286]

Explanation:

The minimum exterior open spaces around buildings that are 55 metres or more, should be 16 metres. On sides where no habitable rooms face, a minimum space of 9 metres shall be left for heights above 27 metres.

3 0
3 years ago
Other questions:
  • All MOS devices are subject to damage from:________
    7·1 answer
  • Consider a fluid with mean inlet temperature Ti flowing through a tube of diameter D and length L, at a mass flow rate m'. The t
    14·1 answer
  • A vegetable freezing plant requires 35 tons of refrigeration. The freezing temperature is – 38°C while the ambient temperature i
    14·1 answer
  • You live on a street that runs East to West. You just had 2 inche of snow and you live on the North side of the street. You retu
    14·1 answer
  • Dampers dampers springs are used inside some valve spring to
    10·1 answer
  • A power plant operates on a regenerative vapor power cycle with one open feedwater heater. Steam enters the first turbine stage
    11·1 answer
  • What sub-discipline of Mechanical Engineering focuses
    10·1 answer
  • How many seconds will it take to cross the street at a normal walking pace?
    15·1 answer
  • Entrence is one of the animation category​
    9·1 answer
  • Which symbol warns that there is something wrong with your alternator?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!