answer.
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
xz_007
2 months 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:
alex41 [359]2 months ago
3 0

Answer:

This is the JAVA code:

import java.util.Scanner; // to capture user input

public class DrawHalfArrow{ // class declaration

public static void main(String[] args) { // main function starts here

    Scanner scnr = new Scanner(System.in); //input reading

int arrowBaseHeight = 0; // variable for arrow base height

int arrowBaseWidth  = 0; // variable for arrow base width

int arrowHeadWidth = 0; // variable for arrow head width

// prompts user for height, base width, and head width

System.out.println("Enter arrow base height: ");

arrowBaseHeight = scnr.nextInt(); // reads integer input

System.out.println("Enter arrow base width: ");

arrowBaseWidth = scnr.nextInt();

/* loop for asking user for arrow head width until it exceeds base width */

while (arrowHeadWidth <= arrowBaseWidth) {

    System.out.println("Enter arrow head width: ");

    arrowHeadWidth = scnr.nextInt(); }

//begin nested loop for base

//outer loop for outputting based on arrow base height

 for (int i = 0; i < arrowBaseHeight; i++) {

//inner loop produces the stars

      for (int j = 0; j <arrowBaseWidth; j++) {

          System.out.print("*");        } //prints stars

          System.out.println();          }

//used for the width of the arrowhead

int k = arrowHeadWidth;

//outer loop for the head height

for (int i = 1; i <= arrowHeadWidth; i++)

{     for(int j = k; j > 0; j--)     {//inner loop for stars

       System.out.print("*");    } //print stars

   k = k - 1;

   System.out.println(); } } } //marks end of asterisks for a new line

Explanation:

The code prompts for arrow dimensions, including height, base width, and head width. The program verifies that the head width must be larger than the base width through a condition. This loop instigates until the user provides a valid head width.

The loop manages the output of the arrow base corresponding to the specified height. Thus point (1) is fulfilled.

A nested loop is utilized to present an arrow base matching the defined width. The inner loop creates stars, establishing the width for the base, while the outer loop iterates according to the specified height. This satisfies point (2).

A temporary variable, k, saves the initial arrow head width for necessary adjustments.

The final nested loop outputs an arrow head corresponding to the specified width with stars. Therefore, point (3) is achieved.

The value of k decreases by 1 for each execution of the nested loop, ensuring each subsequent line contains fewer stars.

The output screenshot is attached.

You might be interested in
Suppose we include the lead resistance in the calculation of temperature for a class A RTD. If R3 = 1000 ohms, Ra = 18 ohms, V0
alex41 [359]

Respuesta:

La temperatura máxima que se puede medir (en °C) es 14170.27°C

Explicación:

Los RTDs son termómetros compuestos de metales cuya resistencia aumenta con la temperatura.

Para un RTD de Clase A, l, Alpha = 0.00385.

La fórmula para el RTD es

Rt = Ro ( 1 + alpha x t)

Donde

Rt es la resistencia a la temperatura t°C,

Ro es la resistencia a 0°C

Alpha es un coeficiente de temperatura constante para un RTD de clase A.

Aquí, Rt = 1000ohms,

Ro se considera como Ra = 18Ohms

Por lo tanto,

1000 = 18 ( 1 + 0.00385t)

Dividiendo ambos lados por 18

1 + 0.00385t = 1000/18

0.00385t = 55.55 - 1

0.00385t = 54.55

t = 54.55/0.00385

t = 14170.27°C

5 0
1 month ago
The first step to merging is entering the ramp and _____.
alex41 [359]

Answer:

D.informing your passengers of your destination

7 0
2 months ago
A cylinder in space is of uniform temperature and dissipates 100 Watts. The cylinder diameter is 3" and its height is 12". Assum
Kisachek [356]

Answer:

Temperature T = 394.38 K

Explanation:

The full solution and detailed explanation regarding the above question and its specified conditions can be found below in the accompanying document. I trust my explanation will assist you in grasping this particular topic.

7 0
2 months ago
Design a decimal arithmetic unit with two selection variables, V1, and Vo, and two BCD digits, A and B. The unit should have fou
choli [298]
Ucsaaaaauxx627384772938282’cc ed un e uff ridicolizzarla +golfista
4 0
2 months ago
A shopaholic has to buy a pair of jeans , a pair of shoes l,a skirt and a top with budgeted dollar.Given the quantity of each pr
choli [298]

Answer:

you may be struggling to pinpoint the separation between your inquiry and my perspective

0 0
3 months ago
Other questions:
  • The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames. Write a program that modifies th
    6·1 answer
  • Who play 1v1 lol unblocked games 76
    8·2 answers
  • Given two input integers for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is 0 1, the output is
    8·1 answer
  • An overhead 25m-long, uninsulated industrial steam pipe of 100-mm diameter, is routed through a building whose walls and air are
    5·1 answer
  • A pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of th
    6·1 answer
  • Consider a very long, slender rod. One end of the rod is attached to a base surface maintained at Tb, while the surface of the r
    8·1 answer
  • A well-insulated rigid tank contains 1.5 kg of a saturated liquid–vapor mixture of water at 200 kPa. Initially, three-quarters o
    10·2 answers
  • Consider the following program:
    15·1 answer
  • Which crystal system(s) listed below has (have) the following relationship for the unit cell edge lengths?
    13·1 answer
  • An electric field is expressed in rectangular coordinates by E = 6x2ax + 6y ay +4az V/m.Find:a) VMN if point M and N are specifi
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!