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
A simple ideal Rankine cycle with water as the working fluid operates between the pressure limits of 4 MPa in the boiler and 20
viktelen [127]

Answer:

a) 69,630KW

b) 203 KW

Explanation:

The data obtained from Tables A-4, A-5 and A-6 is as follows:

h_{1} = h_{f,@20KPa} = 251.42 KJ/kg\\v_{1} = v_{f,@20KPa} = 0.001017 KJ/kgK\\\\w_{p,in} = v_{1} * (P_{2} - P_{1})\\w_{p,in} = (0.001017)*(4000-20)\\\\w_{p,in} = 4.05 KJ/kg\\\\h_{2} = h_{1} - w_{p,in} \\h_{2} = 251.42 + 4.05\\\\h_{2}  =  255.47KJ/kg\\\\P_{3} = 4000KPa\\T_{3} = 700 C\\s_{3} = 7.6214 KJ/kgK\\\\h_{3} = 3906.3 KJ/kg\\\\P_{4} = 20 KPa\\s_{3} = s_{4} = 7.6214KJ/kgK\\s_{f} = 0.8320 KJ/kgK\\s_{fg} = 7.0752 KJ/kgK\\\\

x_{4} = \frac{s_{4} - s_{f} }{s_{fg} }  \\\\x_{4} = \frac{7.6214-0.8320}{7.0752} = 0.9596\\\\h_{f} = 251.42KJ/kg \\h_{fg} = 2357.5KJ/kg \\\\h_{4} = h_{f} + x_{4}*h_{fg} = 251.42 + 0.9596*2357.5 = 2513.7KJ/kg\\\\

The power produced and consumed by turbine and pump respectively are:

W_{T,out} = flow(m) *(h_{3} - h_{4}) \\W_{T,out} = 50 *(3906.3-2513.7)\\\\W_{T,out} = 69,630 KW\\\\W_{p,in} = flow(m) *w_{p,in} = 50*4.05 = 203 KW

7 0
3 years ago
Does anyone know what this is​
sammy [17]

Answer:

Looks like mold that got frosted over

Explanation:

4 0
2 years ago
Read 2 more answers
Identify factors that can cause a process to become out of control. Give several examples of such factors.
Oliga [24]

Answer:

Explained

Explanation:

This situation can occur because of various factors such as:

  • Gradual deterioration of lubrication and coolant.
  • change of environmental condition such as temperature, humidity, moisture, etc.
  • Change in the properties of incoming raw material
  • An increase or decrease in the temperature of the heat treating operation
  • Debris interfering with the manufacturing process.
4 0
3 years ago
Discuss the differences between conduction and convective heat transfer.
FrozenT [24]

Answer:

Basically there are two principal differences between the convection and conduction heat transfer

Explanation:

The conduction heat transfer is referred to the transfer between two solids due a temperature difference, while for, the convective heat transfer is referred to the transfer between a fluid (liquid or gas) and a solid. Also, they used different coefficients for its calculation.

We can include on the explanation that conduction thermal transfer is due to temperature difference, while convection thermal transfer is due to density difference.

8 0
3 years ago
Steam enters a turbine steadily at 7 MPa and 600°C with a velocity of 60 m/s and leaves at 25 kPa with a quality of 95 percent.
Rufina [12.5K]

Answer:

a) \dot m = 16.168\,\frac{kg}{s}, b) v_{out} = 680.590\,\frac{m}{s}, c) \dot W_{out} = 18276.307\,kW

Explanation:

A turbine is a steady-state devices which transforms fluid energy into mechanical energy and is modelled after the Principle of Mass Conservation and First Law of Thermodynamics, whose expressions are described hereafter:

Mass Balance

\frac{v_{in}\cdot A_{in}}{\nu_{in}} - \frac{v_{out}\cdot A_{out}}{\nu_{out}} = 0

Energy Balance

-q_{loss} - w_{out} + h_{in} - h_{out} = 0

Specific volumes and enthalpies are obtained from property tables for steam:

Inlet (Superheated Steam)

\nu_{in} = 0.055665\,\frac{m^{3}}{kg}

h_{in} = 3650.6\,\frac{kJ}{kg}

Outlet (Liquid-Vapor Mix)

\nu_{out} = 5.89328\,\frac{m^{3}}{kg}

h_{out} = 2500.2\,\frac{kJ}{kg}

a) The mass flow rate of the steam is:

\dot m = \frac{v_{in}\cdot A_{in}}{\nu_{in}}

\dot m = \frac{\left(60\,\frac{m}{s} \right)\cdot (0.015\,m^{2})}{0.055665\,\frac{m^{3}}{kg} }

\dot m = 16.168\,\frac{kg}{s}

b) The exit velocity of steam is:

\dot m = \frac{v_{out}\cdot A_{out}}{\nu_{out}}

v_{out} = \frac{\dot m \cdot \nu_{out}}{A_{out}}

v_{out} = \frac{\left(16.168\,\frac{kg}{s} \right)\cdot \left(5.89328\,\frac{m^{3}}{kg} \right)}{0.14\,m^{2}}

v_{out} = 680.590\,\frac{m}{s}

c) The power output of the steam turbine is:

\dot W_{out} = \dot m \cdot (-q_{loss} + h_{in}-h_{out})

\dot W_{out} = \left(16.168\,\frac{kg}{s} \right)\cdot \left(-20\,\frac{kJ}{kg} + 3650.6\,\frac{kJ}{kg} - 2500.2\,\frac{kJ}{kg}\right)

\dot W_{out} = 18276.307\,kW

6 0
3 years ago
Other questions:
  • 6.15. In an attempt to conserve water and to be awarded LEED (Leadership in Energy and Environmental Design) certification, a 20
    14·1 answer
  • For this question, you will be provided with data related to the count of website sessions by day for the past one hundred days.
    6·1 answer
  • Steam at 150 bars and 600°C passes through process equipment and emerges at 100 bars and 700°C. There is no flow of work into or
    8·1 answer
  • How to solve this question
    11·1 answer
  • Is someone an engineer that can help me?plz
    11·1 answer
  • You could be sued if you injure someone while rescuing them if...
    11·2 answers
  • What is the ideal cooling system for low horsepower motor? For example1hp motor
    9·1 answer
  • Please what is dif<br>ference between building technology and building engineering.​
    14·2 answers
  • If you have 300 skittles in a bag and you need to have 28 percent yellow. How many yellow skittles would you have to make a mini
    11·1 answer
  • Workplace bullying can cause_____hazards.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!