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 can you evaluate whether the slope of the dependent variable with an independent variable is the same for each level of the
s2008m [1.1K]

Answer:

By running multiple regression with dummy variables

Explanation:

A dummy variable is a variable that takes on the value 1 or 0. Dummy variables are also called binary

variables. Multiple regression expresses a dependent, or response, variable as a linear

function of two or more independent variables. The slope is the change in the response variable. Therefore, we have to run a multiple regression analysis when the variables are measured in the same measurement.The number of dummy variables you will need to capture a categorical variable

will be one less than the number of categories. When there is no obvious order to the categories or when there are three or more categories and differences between them are not all assumed to be equal, such variables need to be coded as dummy variables for inclusion into a regression model.

3 0
3 years ago
A solid cylindrical workpiece made of 304 stainless steel is 150 mm in diameter and 100 mm is high. It is reduced in height by 5
goblinko [34]

Answer:

45.3 MN

Explanation:

The forging force at the end of the stroke is given by

F = Y.π.r².[1 + (2μr/3h)]

The final height, h is given as h = 100/2

h = 50 mm

Next, we find the final radius by applying the volume constancy law

volumes before deformation = volumes after deformation

π * 75² * 2 * 100 = π * r² * 2 * 50

75² * 2 = r²

r² = 11250

r = √11250

r = 106 mm

E = In(100/50)

E = 0.69

From the graph flow, we find that Y = 1000 MPa, and thus, we apply the formula

F = Y.π.r².[1 + (2μr/3h)]

F = 1000 * 3.142 * 0.106² * [1 + (2 * 0.2 * 0.106/ 3 * 0.05)]

F = 35.3 * [1 + 0.2826]

F = 35.3 * 1.2826

F = 45.3 MN

7 0
3 years ago
Compact fluorescent bulbs are much more efficient at producing light than are ordinary incandescent bulbs. They initially cost m
Ilia_Sergeevich [38]

Answer:

ordinary bulb total cost is $39.54

fluorescent bulb total cost is $13.05

amount save = 39.54 - 13.05 = $26.49

resistance = 626.1 ohm

Explanation:

in the 1st part

bulb on time = 3 year = 4380 hours

life of bulb = 750 h

so number of bulb required = \frac{4380}{750}

number of bulb required = 6

cost of 6 bulb is = 6 × 0.75 = $4.5

so

cost of operation is = 100 × 4380 × \frac{0.08}{1000}

cost of operation = $35.04

so total cost will be = $4.5 + $35.04  = $39.54

and

when compare with florescent bulb

time = 3 year = 4380 h

life of bulb = 10000 h

so number of bulb required = \frac{4380}{10000}

number of bulb required = 0.43 = 1

cost of 6 bulb is = 1 × 5 = $5

so

cost of operation is = 23 × 4380 × \frac{0.08}{1000}

cost of operation = $8.05

so total cost will be = $5 + $8.05  = $13.05

in part 2nd

total amount save while compare bulb is

amount save = 39.54 - 13.05 = $26.49

and in part 3rd

resistance of bulb is

resistance = \frac{v^2}{P}

resistance = \frac{120^2}{23}

resistance = 626.1 ohm

6 0
3 years ago
A reservoir is 1 km wide and 10 km long and has an average depth of 100m. Every hour, 0.1% of the reservoir's volume drops throu
Ksju [112]

Answer:

250.7mw

Explanation:

Volume of the reservoir = lwh

Length of reservoir = 10km

Width of reservoir = 1km

Height = 100m

Volume = 10x10³x10³x100

= 10⁹m³

Next we find the volume flow rate

= 0.1/100x10⁹x1/3600

= 277.78m³/s

To get the electrical power output developed by the turbine with 92 percent efficiency

= 0.92x1000x9.81x277.78x100

= 250.7MW

7 0
3 years ago
The structure of a house is such that it loses heat at a rate of 4500kJ/h per °C difference between the indoors and outdoors. A
adelina 88 [10]

Answer:

15.24°C

Explanation:

The quality of any heat pump pumping heat from cold to hot place is determined by its coefficient of performance (COP) defined as

COP=\frac{Q_{in}}{W}

Where Q_{in} is heat delivered into the hot place, in this case, the house, and W is the work used to pump heat

You can think of this quantity as similar to heat engine's efficiency

In our case, the COP of our heater is

COP_{heater} = \frac{\frac{4500\ kJ}{3600\ s} *(T_{house}-T_{out})}{4\ kW}

Where T_{house} = 24°C and T_{out} is temperature outside

To achieve maximum heating, we will have to use the most efficient heat pump, and, according to the second law of thermodynamics, nothing is more efficient that Carnot Heat Pump

Which has COP of:

COP_{carnot}=\frac{T_{house}}{T_{house}-T_{out}}

So we equate the COP of our heater with COP of Carnot heater

\frac{1.25 *(T_{house}-T_{out})}{4}=\frac{T_{house}}{T_{house}-T_{out}}

Rearrange the equation

\frac{1.25}{4}(24-T_{out})^2-24=0

Solve this simple quadratic equation, and you should get that the lowest outdoor temperature that could still allow heat to be pumped into your house would be

15.24°C

4 0
3 years ago
Other questions:
  • Liquid water enters an adiabatic piping system at 15°C at a rate of 8kg/s. If the water temperature rises by 0.2°C during flow d
    12·1 answer
  • For a copper-silver alloy of composition 25 wt% Ag-75 wt% Cu and at 775°C (1425°F) do the following:
    15·1 answer
  • The penalty for littering 15 lb or less is _____.<br> A. $25<br> B. $50<br> C. $100<br> D. $150
    14·1 answer
  • How would your priorities change if the fine on the library book was $10 a day?
    14·1 answer
  • Do you understand entropy? Why the concept of entropy is difficult to engineering students?
    11·1 answer
  • Q#3:(A)Supose we extend the circular flow mode to add imports and export copy the circular flow digram onto a sheet paper and th
    15·1 answer
  • Compare the temperature dependence of Nabarro-Herring and Coble creep. Which is more temperature-sensitive
    15·1 answer
  • Which is the correct way of dual dimensioning using the position method
    7·1 answer
  • A tool used to put a concave edge on a plane iron is
    6·1 answer
  • Which of these processes uses a die and a press to form parts?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!