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
Identify two related tables in the JustLee Books database. Identify the common field between the two tables. Decide which column
Hatshy [7]

Answer:

Answers explained below

Explanation:

<u>The two related table are: </u>

i) Books Table

ii) BOOKAUTHOR Table

<u>The common field between the two tables are: </u>

i) ISBN attribute

<u>The columns that i would like to display are: </u>

Title, ISBN, AuthorID, PubID, PubDate, Cost, Retail, Discount, Category

<u>Sql Code to join tables using where clause </u>

select t1.Title, t1.ISBN, t2.AuthorID, t1.PubID, t1.PubDate, t1.Cost, t1.Retail, t1.Discount, t1.Category from Books t1 INNER JOIN BOOKAUTHOR t2 ON t1.ISBN = t2.ISBN where t1.ISBN = 0401140733

The above query will dispaly the attributes of table "Books" and of table "BOOKAUTHOR" for book ISBN 0401140733

<u>Repeat problem 1 but remove the WHERE statement </u>

After removing the where condition we will have following join query

select t1.Title, t1.ISBN, t2.AuthorID, t1.PubID, t1.PubDate, t1.Cost, t1.Retail, t1.Discount, t1.Category from Books t1 INNER JOIN BOOKAUTHOR t2 ON t1.ISBN = t2.ISBN

The above query will display all the mapping data of table "Books" and of Table "BOOKAUTHOR"

7 0
4 years ago
On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above mid
lora16 [44]

Answer:

sample output

Enter f0 = 440

440.0,466.1637615180899, 493.8833012561241,

523.2511306011974,  554.3652619537443

Explanation:

import math                                 // math library  

def RaiseToPower():                 //  RaiseToPower method

 r = math.pow(2,1/12)               //r = 2^(1/12)

f0 = float(input('Enter f0 : '))     //input from user

                                               

//a key has a frequency,sy f0

                                                                                                                                     

print(f0,end=' ')                      //Display statement

 for n in range(1,5):                //Iterate the loop up to  the next 4 higher key Hz

n = f0 * math.pow(r,n)         //calculate the fn value

print(fn,end=' ')                   //Display statement

 RaiseToPower()                //Call RaiseToPower method  

                                         

 

         

     

       

7 0
4 years ago
Write a program that will prompt the user to enter an integer. The program should square the number and then print the squared n
Kay [80]

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to compute sum and product

void square(int input)

{

   // variable to store the square of number

   long long squ_num;

   calculate the square of number

   squ_num=pow(input,2);

   // print the output

   cout<<"square of "<< input<<" is: "<<squ_num<<endl;

   

}

// driver function

int main()

{

   int n;

   // read the number until user enter 0

   do{

       cout<<"enter a number!! (0 to stop):";

     // read the input from user

       cin>>n;

       // call the function to calculate square of input number

       square(n);

       

   }while(n!=0);

 

return 0;

}

Explanation:

Declare a variable "n" to read the input number from user.Call the function  square() with parameter "n".In this function, it will calculate the square  of the input number and print it.This will repeat until user enter 0 as  input.Program will ends when user give 0 as input.

Output:

enter a number!! (0 to stop):5                                                                                                                                

square of 5 is: 25                                                                                                                                            

enter a number!! (0 to stop):7                                                                                                                                

square of 7 is: 49                                                                                                                                            

enter a number!! (0 to stop):11                                                                                                                              

square of 11 is: 121                                                                                                                                          

enter a number!! (0 to stop):0

3 0
4 years ago
How to make a negative number positive in excel
Viefleur [7K]

Answer:

DB * -1

Explanation:

Use this formula: DB * -1

DB = Desired Box

DB * -1

4 0
3 years ago
Is anyone else's pa.dl.et not working??? It says The requested URL / was not found on this server. That’s all we know.
hram777 [196]

Don't worry about it

that's happening to other people not just you

i pretty sure it might take a hour or maybe longer for it to start working again

7 0
3 years ago
Other questions:
  • True or false
    7·1 answer
  • Java
    13·1 answer
  • What is the real meaning of hack and crack?
    6·1 answer
  • Name one advantage of modular switches over fixed-configuration switches.
    5·1 answer
  • What are the possible consequences if requirements analysis was done poorly or inadequately? What are the objectives of requirem
    10·1 answer
  • my I phone is in recovery mode and when I connect to my PC the I device is not connected to iTunes although i have the latest ve
    7·2 answers
  • A(n) ________ HTML tag is used to mark information about the page.
    12·1 answer
  • Who knows my sister better?
    15·2 answers
  • Jeni is using the Label Wizard to solve a problem. What problem was she most likely experiencing?
    13·1 answer
  • What happen if ignore the unsafe markings in hand tools in ict​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!