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
svlad2 [7]
4 years ago
11

This program outputs a downwards facing arrow composed of a rectangle and a right triangle. 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.
(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.
(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.
(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width.
while (arrowHeadWidth <= arrowBaseWidth) {
System.out.println("Enter arrow head width: ");
arrowHeadWidth = scnr.nextInt();
}

Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:

Enter arrow base height: 5
Enter arrow base width: 2
Enter arrow head width: 4

**
**
**
**
**
****
***
**
*
Computers and Technology
1 answer:
Maslowich4 years ago
7 0

Answer:

The Java code is given below with appropriate comments for better understanding

Explanation:

<u>// DisplayArrow.java </u>

<u> </u>

import java.util.Scanner;

public class DisplayArrow

{

  public static void main(String[] args)

  {

      Scanner sc=new Scanner(System.in);

   

      int arrowBaseHeight = 0;

      int arrowBaseWidth = 0;

      int arrowHeadWidth = 0;

      int arrowHeadHeight = 0;

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

      arrowBaseHeight = sc.nextInt();

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

      arrowBaseWidth = sc.nextInt();

      // loop to continue prompting the user for an arrow head width

      // until the value is larger than the arrow base width.

      while (arrowHeadWidth <= arrowBaseWidth)

      {

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

          arrowHeadWidth = sc.nextInt();

      }

      System.out.println();

      // 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.

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

      {

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

          {

              System.out.print("*");      

          }  

          System.out.println();

      }

      arrowHeadHeight = arrowHeadWidth;

      // 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.

      for (int i = 0; i < arrowHeadHeight; i++ )

      {

          for (int j = 0; j < arrowHeadWidth; j++ )

          {

              System.out.print("*");      

          }  

          arrowHeadWidth = arrowHeadWidth - 1;

          System.out.println();

      }

  }

}

/*

output:

Enter arrow base height: 5

Enter arrow base width: 2

Enter arrow head width: 4

**

**

**

**

**

****

***

**

*

*/

You might be interested in
Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
padilas [110]

Answer:

There are two customers in the PostalCode.

SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.

SELECT *  FROM Customers  WHERE PostalCode = "44000";

Explanation:

The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.  

In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.  

SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.

6 0
3 years ago
Use port in a sentence
vekshin1

Answer:

The USB port needs to be clear to function correctly.

8 0
3 years ago
Which section in a slide is not visible to the viewers of a presentation, but is visible to the presenter in the normal Slide vi
lyudmila [28]

Answer:

the speakers note

Explanation:

when putting it in presenter view it'll have a separate window so you'll have access and see speaker notes etc

3 0
3 years ago
1. Write a 400-500 word research report about Burke High School.
fenix001 [56]

Answer:

when is it due

Explanation:

6 0
3 years ago
For which tasks is Layout view most helpful? Check all that apply.
Solnce55 [7]

The task where the Layout view most helpful is showing how a report will look when printed.

<h3>What is the Layout view?</h3>

The Layout view is known to be a view that is said to be more of visually-oriented when compared to the Design view.

Note that the Layout view is one where each control often shows real data and as such, The task where the Layout view most helpful is showing how a report will look when printed.

Learn more about  Layout view  from

brainly.com/question/1327497

#SPJ1

6 0
2 years ago
Other questions:
  • Your bank offers to lend you $114,400 at an 8.5% annual interest rate to start your new business. The terms require you to amort
    11·1 answer
  • What output is produced by the following code fragment int num = 1 max = 20 while num &lt; max?
    7·1 answer
  • The following parts were ordered by someone building a personal computer:
    12·1 answer
  • You want to transfer a document from one computer to another, and you want the document to be encrypted. The destination compute
    14·1 answer
  • URLs are directions that browsers follow in order to find specific web page files. What is the first part of the URL that is the
    14·1 answer
  • Design aPayrollclass that has fields for an employee’sname, ID number, hourly pay rate,and number of hours worked. Write theappr
    9·1 answer
  • In a TCP session hijacking attack, if the server is waiting for data starting from sequence number X, but we used X 100 in our a
    13·2 answers
  • What power brake uses vacuum from the engine to aid in brake application?
    6·2 answers
  • Question 1 (1 point)
    9·2 answers
  • In what ways can information be slanted in a news report?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!