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
3 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]3 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
How does the clearance volume affect the efficiency of the Otto cycle?
eduard

Answer:

Explanation:

A smaller clearance volume means a higher compression. A higher compression means better thermal efficiency. However a compression ratio too high might be troublesome, as it can cause accidental ignition of the fuel-air mix. This is the reason why Otto cycle engines have lower compressions that Diesel engines. In a Diesel engine the mix ignites by compression instead of a spark.

7 0
3 years ago
A vertical cylinder (Fig. P3.227) has a 61.18-kg piston locked with a pin, trapping 10 L of R-410a at 10◦C with 90% quality insi
Whitepunk [10]

Hey! How are you? My name is Maria, 19 years old. Yesterday broke up with a guy, looking for casual sex.

Write me here and I will give you my phone number - *pofsex.com*

My nickname - Lovely

4 0
2 years ago
The velocity profile for a thin film of a Newtonian fluid that is confined between the plate and a fixed surface is defined by u
zimovet [89]

Answer:

F = 0.0022N

Explanation:

Given:

Surface area (A) = 4,000mm² = 0.004m²

Viscosity = µ = 0.55 N.s/m²

u = (5y-0.5y²) mm/s

Assume y = 4

Computation:

F/A = µ(du/dy)

F = µA(du/dy)

F = µA[(d/dy)(5y-0.5y²)]

F = (0.55)(0.004)[(5-1(4))]

F = 0.0022N

8 0
3 years ago
Engineering Careers Scavenger Hunt
emmasim [6.3K]

Answer:

c

Explanation:

it's the only engineering career

6 0
3 years ago
Read 2 more answers
6. What types of injuries can occur in an electronics lab and how can they be prevented?
marysya [2.9K]

Answer:

The most common injuries in a chemistry lab is making a fire, heat burns, chemical burns, cuts and scrapes, contamination, inhalation, and spills and breaks.

1.) You can prevent making a fire by making sure you close and seal flammable materials.

2.) You can prevent heat burns by teaching the students how to properly use tongs,water baths, and other cooling equipment. 

3.) You can prevent chemical burns by treating the chemicals with caution, measure carefully, and use the approved containers.

4.) You can prevent cuts and scrapes by telling the students how to use the blades safely, and also when they are disposing broken or sharp items they should know how to wrap them up so no one else will get hurt. 

5.) You can prevent contamination by washing your hands, protect their clothing and skin with a lab coat or a lab apron, gloves and glasses, and cleaning your area where the germs of the chemicals were so no one will become.

6.) You can prevent inhalation by opening up windows, using ventilation fans, and using an equipment that measures the amount of gas emission in a room.

7.) Finally, you can prevent spills and breaks by telling the students what will happen if anything spills, and tell them to clean up.  

8 0
3 years ago
Other questions:
  • 2.14 (a) Using series/parallel resistance reductions, find the equivalent resistance between terminals A and B in the circuit of
    14·1 answer
  • Energy that causes a transfer of heat between marterials
    13·1 answer
  • Find the difference between the first and third angle projection type.
    11·1 answer
  • What are some possible reasons for the sudden development of the cell theory
    14·1 answer
  • If a toy car covers a distance of 42m in 7sec, what is it’s speed
    9·2 answers
  • When you arrive at an intersection with a stop sign in your direction, if there is no marked stop
    14·2 answers
  • Part A What is the correct expression of the internal torque in segment AB? A shaft is fixed at A. A clockwise distributed torqu
    6·1 answer
  • Select the best answer for the question.
    11·2 answers
  • Describe how to use cleaning tools and equipment safely and properly
    6·1 answer
  • How many meters per second is 100 meters and 10 seconds
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!