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
Rudiy27
2 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]2 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
Determine F12 and F21 for the following configurations: (a) A long semicircular duct with diameter of 0.1 meters: (b) A hemisphe
uysha [10]

Answer:

long duct: 1.0 and 0.424

Hemisphere 1.0 ; 0.125; 0.5

Explanation:

For a long duct:

By inspection, F_{12} = 1.0

Calculating by reciprocity, F_{21} = \frac{A_{1} }{A_{2}F_{12}  }  = \frac{2RL}{\frac{3}{4}*2\pi RL  }* 1.0\\                                                         = 0.424

Hemisphere:

By reciprocity gives = 0.125

using the summation rule: F_{21} + F_{22} + F_{23} = 1

However, because this is a hemisphere, the value will be= 0.5 * 1

                                                                                               = 0.5

6 0
2 years ago
140-character statement that completes this sentence: I pledge to not text and drive because...
s2008m [1.1K]

Answer:

its bad and to drive drunk is even worse

4 0
2 years ago
The total floor area of a building, including below-grade space but excluding unenclosed areas, measured from the exterior of th
alex41 [277]

Answer:

Gross building area

Explanation:

The Gross building area refers to the entire area of a building covering all the floors. The measurement is expressed in square feet. The Gross building area also includes basements, penthouses, and mezzanines. It is calculated by estimating the exterior dimension of the building. Storage rooms, laundries, staircases are also a part of the gross building area.

6 0
2 years ago
Let Deterministic Quicksort be the non-randomized Quicksort which takes the first element as a pivot, using the partition routin
juin [17]

Answer:

Answer for the question:

Let Deterministic Quicksort be the non-randomized Quicksort which takes the first element as a pivot, using the partition routine that we covered in class on the quicksort slides. Consider another almost-best case for quicksort, in which the pivot always splits the arrays 1/3: 2/3, i.e., one third is on the left, and two thirds are on the right, for all recursive calls of Deterministic Quicksort. (a) Give the runtime recurrence for this almost-best case. (b) Use the recursion tree to argue why the runtime recurrence solves to Theta (n log n). You do not need to do big-Oh induction. (c) Give a sequence of 4 distinct numbers and a sequence of 13 distinct numbers that cause this almost-best case behavior. (Assume that for 4 numbers the array is split into 1 element on the left side, the pivot, and two elements on the right side. Similarly, for 13 numbers it is split with 4 elements on the left, the pivot, and 8 elements on the right side.)

is given in the attachment.

Explanation:

Download pdf
3 0
2 years ago
The legend that Benjamin Franklin flew a kite as a storm approached is only a legend—he was neither stupid nor suicidal. Suppose
Delicious77 [7]

Answer: 0.93 mA

Explanation:

In order to calculate the current passing through the water layer, as we have the potential difference between the ends of the string as a given, assuming that we can apply Ohm’s law, we need to calculate the resistance of the water layer.

We can express the resistance as follows:

R = ρ.L/A

In order to calculate the area A, we can assume that the string is a cylinder with a circular cross-section, so the Area of the water layer can be written as follows:

A= π(r22 – r12) = π( (0.0025)2-(0.002)2 ) m2 = 7.07 . 10-6 m2

Replacing by the values, we get R as follows:

R = 1.4 1010 Ω

Applying Ohm’s Law, and solving for the current I:

I = V/R = 130 106 V / 1.4 1010 Ω = 0.93 mA

7 0
2 years ago
Other questions:
  • A square loop of wire surrounds a solenoid. The side of the square is 0.1 m, while the radius of the solenoid is 0.025 m. The sq
    6·1 answer
  • Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's
    11·2 answers
  • An art collector is bidding on a statue that would complete a collection he is trying to assemble. The statue is being sold in a
    9·1 answer
  • An aircraft component is fabricated from an aluminum alloy that has a plane-strain fracture toughness of 40 MPa1m (36.4 ksi1in.)
    15·1 answer
  • Air whose density is 0.082 lbm/ft3 enters the duct of an air-conditioning system at a volume flow rate of 450 ft3/min. If the di
    8·2 answers
  • In this module you learned about searching, sorting and algorithms in C++ and how to implement these elements in your C++ progra
    6·1 answer
  • A soil element is subjected to a minor principle stress of 50 kPa on a plane rotated 20 ° counterclockwise from vertical. If the
    10·1 answer
  • An ideal Stirling cycle filled with air uses a 75 F energy reservoir as a sink. The engine is designed to so that the maximum ai
    8·1 answer
  • What are practical considerations you might encounter when you increase the moment of inertia (I) while keeping the cross-sectio
    13·1 answer
  • What term describes a guardrail system
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!