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
Zina [86]
4 years ago
6

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:
Lostsunrise [7]4 years ago
8 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
Assume you are an observer standing at a point along a three-lane roadway. All vehicles in lane 1 are traveling at 30 mi/h, all
garik1379 [7]

Answer:

Explanation:

Given data;

  • In line 1, v1 = 30mi/hr
  • in line 2, v2 = 45mi/hr
  • in line 3, v3 = 60mi/hr
  • therefore time mean speed = v1 + v2 + v3 /n
  • = VT = 45mi/hr

  • space mean speed ; Vs
  • harmonic mean = 1/V = 1/v1 + 1/v2 + 1/v3
  • V = 13.85mi/hr
  • Hence Vs = V x n = 3 x 13.85 = 41.55mi/hr
5 0
3 years ago
20 points and brainliest A, B, C, D
Annette [7]
B !! Is the correct answer
5 0
3 years ago
Read 2 more answers
Write a function called largest3 which takes 3 numbers as parameters and returns the largest of the 3. Write a program which tak
tamaranim1 [39]

Answer:

The solution code is written in Python.

  1. def largest3(num1, num2, num3):
  2.    largest = num1
  3.    if(largest < num2):
  4.        largest = num2
  5.    
  6.    if(largest < num3):
  7.        largest = num3
  8.    
  9.    return largest
  10. first_num = int(input("Enter first number: "))
  11. second_num = int(input("Enter second number: "))
  12. third_num = int(input("Enter third number: "))
  13. largest_number = largest3(first_num, second_num, third_num)
  14. print("The largest number is " + str(largest_number))

Explanation:

<u>Create function largest3</u>

  • Firstly, we can create a function <em>largest3 </em>which take 3 numbers (<em>num1, num2, num3</em>) as input. (Line 1).
  • Please note Python uses keyword <em>def </em>to denote a function. The code from Line 2 - 10 are function body of <em>largest3</em>.
  • Within the function body, create a variable,<em> largest</em>, to store the largest number. In the first beginning, just tentatively assign<em> num1 </em>to<em> largest</em>. (Line 2)
  • Next, proceed to check if the current "<em>largest</em>" value smaller than the<em> num2 </em>(Line 4). If so, replace the original value of largest variable with <em>num2</em> (Line 5).
  • Repeat the similar comparison procedure to<em> </em><em>num3</em> (Line 7-8)
  • At the end, return the final value of "<em>largest</em>" as output

<u>Get User Input</u>

  • Prompt use input for three numbers (Line 13 -15) using Python built-in <em>input</em> function.
  • Please note the input parts of codes is done outside of the function <em>largest3</em>.

<u>Call function to get largest number and display</u>

  • We can simply call the function<em> largest </em>by writing the function name <em>largest</em> and passing the three user input into the parenthesis as arguments. (Line 17)
  • The function <em>largest </em>will operate on the three arguments and return the output to the variable <em>largest_number</em>.
  • Lastly, print the output using Python built-in <em>print</em> function. (Line 18)
  • Please note the output parts of codes is also done outside of the function<em> largest3</em>.
6 0
3 years ago
If you were to plot the voltage versus the current for a given circuit, what would you expect the slope of the line to be? If no
Brut [27]

Answer:

Part 1: It would be a straight line, current will be directly proportional to the voltage.

Part 2: The current would taper off and will have negligible increase after the voltage  reaches a certain  value. Graph attached.

Explanation:

For the first part, voltage and current have a linear relationship as dictated by the Ohm's law.

V=I*R

where V is the voltage, I is the current, and R is the resistance. As the Voltage increase, current is bound to increase too, given that the resistance remains constant.

In the second part, resistance is not constant. As an element heats up, it consumes more current because the free sea of electrons inside are moving more rapidly, disrupting the flow of charge. So, as the voltage increase, the current does increase, but so does the resistance. Leaving less room for the current to increase. This rise in temperature is shown in the graph attached, as current tapers.

7 0
4 years ago
How many ticks are in a inch?<br><br><br> A: 12<br> B: 10<br> C: 8<br> D: 16
slamgirl [31]

Answer:

16

Explanation:

since each tick is 1/16 of the inch, there will be 16 ticks

4 0
3 years ago
Other questions:
  • What is the function of the following: 1- Oil rings 2- Flywheel 3- Timing gears
    10·1 answer
  • How high does receptacles have to be in a house
    14·1 answer
  • A 16-lb solid square wooden panel is suspended from a pin support at A and is initially at rest. A 4-lb metal sphere is shot at
    8·1 answer
  • (a) What is the distinction between hypoeutectoid and hypereutectoid steels? (b) In a hypoeutectoid steel, both eutectoid and pr
    7·2 answers
  • 19. Write a C program that converts an uppercase character to a lowercase character. Declare function char toLower(char ch); to
    5·1 answer
  • How Much do Biomedical Engineers Earn?
    10·2 answers
  • 10.0 kmol of a 40.0 mol% methanol and 60.0 mol% water mixture is processed in a normal batch distillation system with a still po
    9·1 answer
  • Which of these people is an engineer?
    13·1 answer
  • Pleaseee help! 100 points!!!!!!!!!!!!!! geometry angles in parallel lines question.
    8·1 answer
  • Can I get an answer to this question please
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!