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
Drag each tile to the correct box.
Trava [24]

Answer:

Bluray

DVD

CD

Explanation:

Blu ray can hold 25gb per layer

Dvd can hold 4.7GB on a single layer

Cd can hold around 737 mb

Also, dvds can go up to 2 layers

Blu ray can go up to 4

6 0
3 years ago
For each topic, find the total number of blurts that were analyzed as being related to the topic. Order the result by topic id.
photoshop1234 [79]

Answer:

Explanation: see attachment below

8 0
3 years ago
If the surface energy of a magnesium oxide - nickel oxide (MgO-NiO) solid solution is 1.05 J/m2 and its elastic modulus is 198 G
Nastasia [14]

Answer:

The maximum length is 3.897×10^-5 mm

Explanation:

Extension = surface energy/elastic modulus

surface energy = 1.05 J/m^2

elastic modulus = 198 GPa = 198×10^9 Pa

Extension = 1.05/198×10^9 = 5.3×10^-12 m

Strain = stress/elastic modulus = 27×10^6/198×10^9 = 1.36×10^-4

Length = extension/strain = 5.3×10^-12/1.36×10^-4 = 3.897×10^-8 m = 3.897×10^-8 × 1000 = 3.897×10^-5 mm

7 0
3 years ago
A welding rod with κ = 30 (Btu/hr)/(ft ⋅ °F) is 20 cm long and has a diameter of 4 mm. The two ends of the rod are held at 500 °
SOVA2 [1]

Answer:

In Btu:

Q=0.001390 Btu.

In Joule:

Q=1.467 J

Part B:

Temperature at midpoint=274.866 C

Explanation:

Thermal Conductivity=k=30  (Btu/hr)/(ft ⋅ °F)= \frac{30}{3600} (Btu/s)/(ft.F)=8.33*10^{-3}  (Btu/s)/(ft.F)

Thermal Conductivity is SI units:

k=30(Btu/hr)/(ft.F) * \frac{1055.06}{3600*0.3048*0.556} \\k=51.88 W/m.K

Length=20 cm=0.2 m= (20*0.0328) ft=0.656 ft

Radius=4/2=2 mm =0.002 m=(0.002*3.28)ft=0.00656 ft

T_1=500 C=932 F

T_2=50 C= 122 F

Part A:

In Joules (J)

A=\pi *r^2\\A=\pi *(0.002)^2\\A=0.00001256 m^2

Heat Q is:

Q=\frac{k*A*(T_1-T_2)}{L} \\Q=\frac{51.88*0.000012566*(500-50}{0.2}\\ Q=1.467 J

In Btu:

A=\pi *r^2\\A=\pi *(0.00656)^2\\A=0.00013519 m^2

Heat Q is:

Q=\frac{k*A*(T_1-T_2)}{L} \\Q=\frac{8.33*10^{-3}*0.00013519*(932-122}{0.656}\\ Q=0.001390 Btu

PArt B:

At midpoint Length=L/2=0.1 m

Q=\frac{k*A*(T_1-T_2)}{L}

On rearranging:

T_2=T_1-\frac{Q*L}{KA}

T_2=500-\frac{1.467*0.1}{51.88*0.00001256} \\T_2=274.866\ C

4 0
3 years ago
how are the construction steps for bisecting an angle similar to the steps you would have taken to construct and bisect a line s
GREYUIT [131]

Answer:

does the question entail anything else?

Explanation:

5 0
3 years ago
Other questions:
  • As you discovered in lab last week, the advantage of CMOS logic is that no drain current flows through the MOSFETs when the outp
    14·1 answer
  • How do scientists and engineers use math to help them?
    14·1 answer
  • The water in an 8-m-diameter, 3-m-high above-ground swimming pool is to be emptied by unplugging a 3-cm-diameter, 25-m-long hori
    9·1 answer
  • What do you need for an object to fly?
    10·1 answer
  • Briefly explain how each of the following influences the tensile modulus of a semicrystalline polymer and why:(a) molecular weig
    6·1 answer
  • Let CFG G be the following grammar.
    7·2 answers
  • There is a black-box system (i.e we do not know the transfer function of the system). When we fed a step input into the system,
    9·1 answer
  • A coil consists of 200 turns of copper wire and have a cross-sectional area of 0.8 mmm square.The mean length per turn is 80 cm
    13·1 answer
  • Which statement about cathode ray tubes (CRTs) is true?
    13·1 answer
  • Connect wires to make the correct logic outputs.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!