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
Which of the following describes the wireless standard?
Maksim231197 [3]
The awnswer is a. 802.11
7 0
3 years ago
Read 2 more answers
A well-insulated, rigid vessel contains 3 kg of saturated liquid water at 40°C. The vessel also contains an electrical resistor
fenix001 [56]

Answer:

The final temperature in the vessel after the resistor has been operating for 30 min is 111.67°C

Explanation:

given information:

mass, m = 3 kg

initial temperature,  T₁ = 40°C

current, I = 10 A

voltage, V = 50 V

time, t = 30 min = 1800 s

Heat for the system because of the resistance is

Q = V I t

where

V = voltage (V)

I = current (A)

t = time (s)

Q = heat transfer to the system (J)

so,

Q = V x I x t

   = 50 x 10 x 1800

   = 900000

   = 9 x 10⁵ J

the heat transfer in the closed system is

Q = ΔU + W

where

U = internal energy

W = work done by the system

thus,

Q = ΔU + W

9 x 10⁵ = ΔU + 0, W = 0 because the tank is a well-insulated and rigid.

ΔU = 9 x 10⁵ J = 900 kJ

then, the energy change in the system is

ΔU = m c ΔT

ΔT = ΔU / m c, c = 4.186 J/g°C

     = 900 / (3 x 4.186)

     = 71.67°C

so,the final temperature (T₂)

ΔT = T₂ - T₁

T₂ = ΔT + T₁

    = 71.67°C + 40°C

    = 111.67°C

7 0
3 years ago
For the velocity fields given below, determine:
o-na [289]

Answer and Explanation: A fluid flow is <u>steady</u> when its properties (velocity, pressure and others) <u>do</u> <u>not</u> change over time: P = P(x,y,z), with P being any of the properties.

So, an unsteady flow does depend upon time: P = P(x,y,z,t).

1. V = [ay2e^{-bt}]i : This velocity field is one-dimension, because there is only the component in the x-direction and unsteady, because it is dependent upon the variable time (t);

2. V = ax^{2}i+bxj+ck : is a three-dimensional field, because there is one component for each direction (x, y and z) and is steady, since it's independent of time;

3. V = axyi - bytj : is a 2-dimensional field, and since it changes with time, it is unsteady;

4. V = axi - byj + ctk : is a 3-dimensional field and the flow is unsteady;

6 0
3 years ago
A customer asks why rogue has a vc-turbo engine when turbo engines are for sports cars. What are two ways to respond?.
aniked [119]

Best-in-class gas engine 1 and torque 2 fuel economy and All-new engine to be assembled at Nissan's powertrain facility in Decherd, Tenn.

<h3>Rogue</h3>

Nissan has introduced an all-new Rogue for the 2021 model year, delivering high quality and customer satisfaction through its strong combination of design, safety and technology. Now, for 2022, Nissan is making its best-selling model more powerful, more fuel efficient and more fun to drive with a new 1.5-liter Variable Compression (VC) Turbo engine across the Rogue lineup.

With this information, we can conclude that the vc-turbo engine is a great advance for fuel economy.

Learn more about Nissan in brainly.com/question/24814294

7 0
3 years ago
Connect wires to make the correct logic outputs.
Aleksandr [31]

Answer:

Explanation:

im dum sorry bro i don't know it im in 6 grade

8 0
3 years ago
Other questions:
  • You should be extra careful during the hours of sunrise, sunset, and nighttime because _____. A. of increased law enforcement ac
    11·1 answer
  • A sandy soil has a total unit weight of 120 pcf, a specific gravity of solids of 2.64, and a water content of 16 percent. Comput
    13·1 answer
  • Can you tell me important facts about Peggy A. Whitson?
    13·2 answers
  • A simple formula to estimate the upward velocity of a rocket (neglecting the aerodynamic drag) is:
    9·1 answer
  • How to build a laser pointer?
    12·1 answer
  • Help please thank you​
    15·1 answer
  • A Barnes and Books is interested in purchasing a two-story building for a new
    5·1 answer
  • Una frase de: ama la vida quien___________________________________
    6·1 answer
  • Argue which step in the modeling process is most important to a designer turning a plain gray model of headphones into a stylish
    8·1 answer
  • Which is the best description of power? A. the amount of kinetic energy lost during motion
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!