CIS22A Homework 8
Spring 2022

Topic:
A function with parameters passed by value and passed by reference (Chapter 6.13, Lecture 6/6/22)
Do not use anything beyond Chapter 6 materials.
Do not use C++ pointers (this is not a topic of this course).

Write a program to read the base and the hypotenuse of an isosceles triangle and calculate the height and the area of the triangle.

In the picture above a is the base, b is the hypotenuse, and h is the height.

The formulas are:




where A is the area.
https://mathworld.wolfram.com/IsoscelesTriangle.html

Write a single function isoscelesTriangleHeightAndArea (base, hypotenuse, height, area) that calculates both the height and area of an isosceles triangle given its base length and hypotenuse length.

There must be no other function in the program beside isoscelesTriangleHeightAndArea() and main()


The function isoscelesTriangleHeightAndArea (base, hypotenuse, height, area) has EXACTLY FOUR PARAMETERS.
-Input parameters to the functions are the base and hypotenuse of the triangle. Function cannot modify the input parameters.
-Output parameters of the function are the area and height of the triangle. Function must calculate and modify these 2 parameters.
-Function must have a boolean return (success or failure) to indicate whether the calculation is successful or not.
-This function returns true if both base and hypotenuse are not negative (0 base is valid).
There is also a validation rule that the following expression cannot be negative to avoid calculation of square root of a negative number.

If validation fails then the function returns false and skips all calculations.

-The function isoscelesTriangleHeightAndArea() should Not use any "cin" or "cout". Only the main() function will contain "cin" and "cout".
-The main() function calls the function in a loop until the user enters 0 0. These are the "Sentinel" values that stop the loop (chapter 5). If only one input is 0 and the other input is positive, the loop will keep going.
-Use variable name base and hypotenus, not a and b.

The following is a basic simple code without loop to test your function:
#include
#include
// Function prototype
// —-----------
int main()
{
double base = 2.5, hypotenuse = 3, height, area;
bool success = isoscelesTriangleHeightAndArea(base, hypotenuse, height, area);
if (success)
{
cout << "Triangle height is " << height << endl;
cout << "Triangle area is " << area << endl;
}
else
cout << "Invalid Input!" << endl;

// Expected output is:
// Triangle height is 2.72718
// Triangle area is 3.40897
}

Output is:
Triangle height is 2.72718
Triangle area is 3.40897

You can use this web calculator here to verify results:
https://keisan.casio.com/exec/system/1273850202


It is not required that you have to copy and paste the above code to your code for submission. But the code gives you an excellent guide of how to write the function prototype so that the test code above works correctly.

If your function code does not work with the above given main() code, your score will be very low because the function is incorrect.

The result of the function call is used in main() to decide what to display for the output: if the return value is true then it means the calculation result is stored in area and height, and if false it means that the input parameters base and hypotenuse are invalid.

After using the simple test code above, write code in main() to accept multiple base and hypotenuse inputs and display the results by writing a Sentinel loop (chapter 5, lecture 5/23/22) that runs until the user enters 0 and 0 for the 2 inputs.

Note:
Do not use an infinite loop as a sentinel loop.
Do not use "break" statements.
A good sentinel loop does not use an extra "if" statement inside loop to check for the sentinel value 0 and 0.
If the sentinel loop is correct, the function is NOT called when input is 0 and 0 because these values will make the loop stop.
There is no need to control the number of decimal digits in the results
The output text and results should be aligned nicely as seen in the following samples.

Write the function prototype before main() and write the full function definition after main().

Output samples

Answers

Answer 1

The program is an illustration of C++ functions;

Functions are program statements that are executed when evoked

The C++ program

The program in C++, where comments are used to explain each action is as follows:

#include <iostream>

#include <cmath>

using namespace std;

//This defines the boolean method

bool isoscelesTriangleHeightAndArea(double base, double hypotenuse, double height, double area) {

   //This checks for invalid base and height

   if(base < 0 || hypotenuse < 0){

       return false;

   }

   //This returns true if base and height are valid

   return true;

}

//The main begins here

int main(){

   //This initializes the variables

   double base, hypotenuse, height, area;

   //This gets input for base and hypotenuse

   cout<<"Base: ";    cin>>base;

   cout<<"Hypotenuse: "; cin>>hypotenuse;

   //The calls the boolean method

   bool success = isoscelesTriangleHeightAndArea(base, hypotenuse, height, area);

   //If success is True

   while (success){

       //This calculates height

       height = sqrt(hypotenuse*hypotenuse - (base/2) * (base/2));

       //This calculates area

       area = 0.5 * base * height;

       //This prints height

       cout << "Triangle height is " << height << endl;

       //This prints area

       cout << "Triangle area is " << area << endl;

       //This gets input for base and hypotenuse

       cout<<"Base: ";    cin>>base;

       cout<<"Hypotenuse: "; cin>>hypotenuse;

       bool success = isoscelesTriangleHeightAndArea(base, hypotenuse, height, area);

   }

   cout << "Invalid Input!" << endl;

}

Read more about C++ programs at:

https://brainly.com/question/24833629

#SPJ1


Related Questions

The introduction of this material into the nineteenth-century industrial age forever changed architectural style and scale. Group of answer choices mortar steel hexagonal plates precast concrete

Answers

The introduction of steel into the nineteenth-century industrial age changed the architectural style and scale forever.

What is steel?

Steel can be defined as hard, strong, tough grey (bluish-grey) alloy of iron and carbon that is typically used as a structural and fabricating material in Civil engineering and architecture.

During the industrial age of the nineteenth-century, the introduction of steel changed the architectural style and scale forever.

Read more on steel here: https://brainly.com/question/1836801

#SPJ1

A pin connection supports a load. Which type of connection would result in the smallest shear stress in the pin

Answers

Answer:

A single- shear pin connection.

Explanation:

n a steel floor framing system, No. 8 screws spaced at a maximum of __________ inches on center on the edges and _________ inches on center at the intermediate supports shall be used to fasten the subfloor to the floor joists.

Answers

Answer:

In a steel floor framing system, No. 8 screws spaced at a maximum of 6 inches on center on the edges and 12 inches on center at the intermediate supports shall be used to fasten the subfloor to the floor joists.

Explain about pitching and floating type wave energy converter with necessary diagram.

Answers

Explain about pitching and floating type wave energy converter with necessary diagram

Wave power converts the periodic up-and-down movement of the oceans waves into electricity by placing equipment on the surface of the oceans that captures the energy produced by the wave movement and converts this mechanical energy into electrical power.

What pattern that used for validating a real number?

Answers

Answer:

a phone number for a region using length and prefix information

Explanation:

Write this tension as a vector in both the cases.

Answers

The tension acting on point A is represented by the equation [tex]\vec {T}_{A} = T_{AB}\cdot \left(-\frac{6.150}{10.483}\,\hat{i} - \frac{5.8}{10.483}\,\hat{j} + \frac{6.2}{10.483}\,\hat{k} \right)[/tex] and the tension acting on point B is represented by the equation [tex]\vec {T}_{B} = T_{AB}\cdot \left(\frac{6.150}{10.483}\,\hat{i} +\frac{5.8}{10.483}\,\hat{j} - \frac{6.2}{10.483}\,\hat{k} \right)[/tex].

How to express a tension in vector form

Vectors are numbers characterized by magnitude and direction. In this question we must represents a tension in the form of a vector. Please notice that tension is a reactive force caused by the action of an external force, often indirectly, in which the string is elongated.

The total length of the string is found by Pythagorean Theorem:

[tex]l_{AB} = \sqrt{[2.5\,m +(5.8\,m)\cdot \sin 39^{\circ}]^{2}+(5.8\,m)^{2}+(6.2\,m)^{2}}[/tex]

[tex]l_{AB} \approx 10.483\,m[/tex]

First, the tension acting on point A is:

[tex]\vec {T}_{A} = T_{AB}\cdot \left(-\frac{6.150}{10.483}\,\hat{i} - \frac{5.8}{10.483}\,\hat{j} + \frac{6.2}{10.483}\,\hat{k} \right)[/tex]

Lastly, the tension acting on point B is:

[tex]\vec {T}_{B} = T_{AB}\cdot \left(\frac{6.150}{10.483}\,\hat{i} +\frac{5.8}{10.483}\,\hat{j} - \frac{6.2}{10.483}\,\hat{k} \right)[/tex]

The tension acting on point A is represented by the equation [tex]\vec {T}_{A} = T_{AB}\cdot \left(-\frac{6.150}{10.483}\,\hat{i} - \frac{5.8}{10.483}\,\hat{j} + \frac{6.2}{10.483}\,\hat{k} \right)[/tex] and the tension acting on point B is represented by the equation [tex]\vec {T}_{B} = T_{AB}\cdot \left(\frac{6.150}{10.483}\,\hat{i} +\frac{5.8}{10.483}\,\hat{j} - \frac{6.2}{10.483}\,\hat{k} \right)[/tex].

To learn more on tension: https://brainly.com/question/2287912

#SPJ1

A single-phase transformer circuit feeds a motor and lighting load of 50 kilowatts. At a power factor of .8, the KVA rating of the step down transformer would be

Answers

The KVA rating of the step down transformer at the given power factor would be 62.5 kVA.

What is power factor of a transformer?

Power factor (PF) is the ratio of working power, measured in kilowatts (kW), to apparent power, measured in kilovolt amperes (kVA).

PF = working power / apparent power

PF =  kW/kVA

kVA = kW/PF

kVA = 50 kW/0.8

kVA = 62.5 kVA

Thus, the KVA rating of the step down transformer at the given power factor would be 62.5 kVA.

Learn more about power factor here: https://brainly.com/question/7956945

#SPJ1

A one-story office building measures 225 feet by 350 feet. After the lighting calculations are completed, what are the additional load calculations for general-purpose receptacle outlets, when the actual number of general-purpose receptacle outlets is unknown

Answers

The additional load calculations for general-purpose receptacle outlets would be equal to 18750.

What are receptacles?

A touch device set up at the opening for the connection of an attachment plug is called a receptacle. A single receptacle is a single touch tool without a different touch tool at an equal yoke. A couple of receptacles are or greater touch devices at the equal yoke.

Therefore, The additional load calculations for general-purpose receptacle outlets would be equal to 18750.

Learn more about receptacles:

https://brainly.com/question/27296626

#SPJ1

pressure tunnel and tunnel lining are the types of tunnels? ​

Answers

Answer:

the support system of tunnel or shaft

Explanation:

i just looked it up

What person at the construction worksite keeps workers safe from asbestos exposure?

A. Trained person
B. Capable person
C. Competent person
D. Qualified person

Answers

Answer:

With doing research on this topic, I found that it is most likely A. Trained person. If I'm incorrect, I greatly apologize.

Explanation:

The _____ is installed in the liquid ine and is responsible for removing moisture and foreign matter.

Answers

Answer:

filter drier

Explanation:

Any refrigeration or air conditioning system needs filter driers as a crucial part. In a refrigeration or air conditioning system, a filter drier serves two crucial purposes: first, it adsorbs system impurities like water, which can produce acids, and second, it provides physical filtering. To guarantee optimal and cost-effective dryer design, each component must be evaluated. The most crucial role of a dryer is to be able to drain water from a refrigeration system. Water can originate from a variety of places, including motor windings, equipment leaks, retained air from poor drainage, and others.

Small steel balls fall from rest through the opening at A at the steady rate of two per second. Find the vertical separation h of two consecutive balls when the lower one has dropped 3 meters. Neglect air resistance.

Answers

Answer:

2.61 m separation

Explanation:

x = xo + vo t + 1/2 at^2      x o   and vo = 0   so this becomes

x  = 1/2 at^2

Find t    when   x = 3

3 = 1/2 (9.81)(t^2)

t = .782 sec

then the SECOND ball is at

x = 1/2 a t^2           but t is reduce by 1/2 second drop rate

x = 1/2 (9.81)(.782 - .5)^2 = .39  m

3 - .39  m = 2.61 m

How far away must a pwc stay from anyone being towed behind another vessel?.

Answers

Answer:

5 lengths away or 50-100 feet

Explanation:

I would say and from what I found 5 lengths away or 50-100 feet

A nanometer connected to a pipe indicates a negative gauge pressure of 70mm of mercury .what is the pressure in the pipe in N/m^2?

Answers

Based on the calculations, the absolute pressure in the pipe is equal to 90,670.4‬ N/m².

How to calculate the absolute pressure?

Mathematically, absolute pressure can be calculated by using this formula:

[tex]P_{abs} = P_{atm} + P_{guage}[/tex]

Scientific data:

Atmospheric pressure (Patm) = 1 bar = 1 × 10⁵ N/m²

Head (h) = -70mmhg = -0.07 m hg

Acceleration due to gravity = 9.8 m/s²

Density of mercury = 13,600 kg/m³.

Next, we would determine the gauge pressure:

[tex]P_{guage} = \rho gh\\\\P_{guage} = -13600 \times 9.8 \times 0.07\\\\P_{guage} = -9,329.6\;N/m^2[/tex]

Now, we can calculate the absolute pressure:

[tex]P_{abs} = P_{atm} + P_{guage}\\\\P_{abs} = 1 \times 10^5 - 9329.6[/tex]

Absolute pressure = ‭90,670.4‬ N/m².

Read more on absolute pressure here: brainly.com/question/10013312

#SPJ1

You are getting ready to transport troops in an M1152 configured with cargo cover and troops seats. Which of the following should you do before starting out?

Answers

Answer:

I believe it would be to lower the troop seats.

Explanation:

How much wood is needed to cut 6 pieces, 4 1/2 inches long for a project. the saw blades kerf is 1/8 of an inch.

Answers

The total length of the wood needed will be 27 inches.

How to calculate the length?

From the information given, it was stated that each wood is about 4 1/2 inches and that 6 pieces will be needed.

The length of the total woods needed will be:

= 4 1/2 × 6

= 9/2 × 6

= 27 inches.

Learn more about length on:

brainly.com/question/2217700

#SPJ1

reason fo I.EE regulations in electrical installations​

Answers

Answer:

The IEE Wiring Regulations Explained and Illustrated, Second Edition discusses the recommendations of the IEE Regulations for the Electrical Equipment of Buildings for the safe selection or erection of wiring installations. The book emphasizes earthing, bonding, protection, and circuit design of electrical wirings.

Explanation:

i hope it help you please make me brainlist and answer my question

Rivet gauge, or transverse pitch is the distance between the Group of answer choices heads of rivets in the same row. centers of rivets in adjacent rows. centers of adjacent rivets in the same row. g

Answers

Rivet gauge or transverse pitch is the distance between the Group of answer is centers of adjacent rivets in the same row.

What is the Rivet gauge?

The gauge distance is the transverse distance among consecutive rivets of adjoining chains (parallel adjoining traces of fasteners) and is measured at proper angles to the path of the pressure withinside the structural member.

The distance among facilities of any adjoining rivets parallel to the path of pressure is known as pitch.

Read more about the  transverse pitch:

https://brainly.com/question/20527188

#SPJ1

Derive the expression ε=ln(1+e), where ε is the true strain and e is the engineering strain. Note that this expression is not valid after the onset of necking

Answers

The formula for true strain after derivation from basic terms is; ε_t = In(1 + ε_e)

How to derive the expression for True Strain?

Formula for Engineering Stress is;

σ_e = Load/Area

Formula for true stress is;

σ_t = Force/Instantaneous Area

Formula for Engineering Strain is;

ε_e = ΔL/L₀

Formula for true strain is;

dε_t = dL/L

Total true strain is gotten from;

ε_t = ∫(dL/L) between boundaries of L_f and L_o

When we integrate between those boundaries, we have;

ε_t = In[(L₀ + ΔL)/L₀

⇒ ε_t = In[(1+ ΔL/L₀)

⇒ ε_t = In(1 + ε_e)

Read more about True Strain at; https://brainly.com/question/20717759

#SPJ1

How is conduit size calculated when wires of two or more sizes are used?

Answers

Divide the number of each gauge and kind of wires by the wire diameter is conduit size calculated when wires of two or more sizes are used.

What are some common uses of wire?

Here are some typical applications for wire shapes. Additionally, a lot of electrical applications use wire shapes.

  Baggage label clips.    Electrical switchgear.    Light fittings.    Hooks.    Telecommunications equipment.    Textile machinery.    Safety equipment.

Thus, Divide the number of each gauge and kind of wires by the wire diameter

For more details about some common uses of wire, click here:

https://brainly.com/question/15412994

#SPJ1

When bending metal, the material on the outside of the curve stretches while the material on the inside of the curve compresses. That part of the material which is not affected by either stress is the g

Answers

That part of the material which is not affected by either stress is the neutral line or axis.

What is the technique known as whilst you bend steel?

Sheet Metal Bending – Methods, Design Tips & K Factor. Bending is one of the maximum not unusual place sheet steel fabrication operations. Also referred to as press braking, flanging, die bending, folding and edging, this technique is used to deform a cloth to an angular shape. This is finished thru the utility of pressure on a workpiece.

The neutral axis is in which neither the fabric stretches nor is compressed. Hence, the duration of the nuetral axis lives the identical earlier than and after the bending operation.

Read more about the bending :

https://brainly.com/question/13637124

#SPJ1

The release of a tendon from adhesions is known as _____. This procedure is the opposite of tenodesis.

Answers

Answer:

The answer is tenolysis

Please help me with this question

Answers

Answer:

The answer is c and the teacher helped me

Explanation:

i had help from the tescger and the assignment is done

With the changing demand patterns, fewer full bins are being required and a
greater proportion of goods need to be picked at the picking stations. What
alternatives may be considered to accommodate this?
Should home shopping continue to have its own dedicated area within the
SANDC, with its own inventory and OSR equipment? How flexible is a
SANDC to such changes in demand patterns, and what are likely to be the key
implementation issues for any future operational change?
• Continuous improvement is being sought in all operations. How can the present
SANDC operation be improved still further in terms of efficiency, service levels,
ergonomics and sustainability? What areas may be worthy of examination?

Answers

The alternative that could be thought of in order to accommodate changing demand patterns is to increase the number of bins to manage the picking of orders which would accommodate a large number of orders from diverse customers.

What alternatives may be considered to accommodate this?

To accommodate changing demand patterns, the number of picking stations and number of pickers can also be increased in order to manage the orders of customers efficiently.

Home shopping should continue to have its own dedicated area within the SANDC, with its own inventory and OSR equipment as it helps for easier assemblage and storage.

Learn more about demand on:

https://brainly.com/question/1245771

#SPJ1

Integrated circuits typically are mounted on ________, which are then plugged into the system board.

Answers

Answer:

chip carriers

Explanation:

The components of a transistor or an integrated circuit are contained on a chip carrier. It is also frequently referred to as a chip container or chip package. With the help of this packaging, the chips can be connected or plugged into a circuit board without risking damage to their delicate components. As chip carriers have shrunk in size to accommodate new technologies, the procedure of installing them has grown more complicated.

Technician A says the pressure cycling switch directly opens and closes the electrical circuit to the compressor clutch coil. Technician B says the pressure cycling switch sends a signal to the microprocessor to turn the compressor on and off. Who is correct

Answers

In the given case, the statements expressed by Technician A and Technician B about the pressure cycling switch are correct. Therefore, Both Technicians A and B are correct.

What is the motive of the pressure switch?

Pressure switches are critical components for controlling the activation and deactivation of pumps in fluid structures while pressure thresholds are reached. They also are utilized in procedure control systems for keeping steady pneumatic or mechanical pressure.

Therefore, In the given case, the statements expressed by Technician A and Technician B about the pressure cycling switch are correct. Both Technicians A and B are correct.

Learn more about Pressure switches:

https://brainly.com/question/24784953

#SPJ1

During delivery of a 2023 ariya equipped with propilot assist 2. 0, what should you point out to your customers about the turn signal stalk?.

Answers

You should point out to your customers that the turn signal stalk should be turned ON when they are about 100 feet away from an intersection.

What is a turn signal stalk?

A turn signal stalk can be defined as a slender lever which is usually mounted on or near the steering wheel of an automobile vehicle, and it's used by a driver to control a signal or perform a function.

In conclusion, it is very important that you should point out to your customers that the turn signal stalk should be turned ON when they are about 100 feet away from an intersection.

Read more on an intersection here: https://brainly.com/question/22580476

#SPJ1

The starting device usually used on single phase, fractional horsepower motors requiring low starting torque is the

Answers

The starting device usually used on single-phase, fractional horsepower motors requiring low starting torque is the current relay.

How tons cutting-edge relay is wanted energized?

This is the minimal cutting-edge, the relay expects to float thru the now shorted contacts whilst the relay is became on (forty mA). The load may be much less than that too however relay won't stay sufficient for range of cycles of operation referred to withinside the information sheet. The minimum running voltage to your precise relay is 3. seventy-five V.

A cutting-edge relay is a kind of electromagnetic transfer used as a part of the manipulating structures for electric equipment. These relays are generally used as sensors (cutting-edge sensor/tracking relays) to screen cutting-edge float inside the business and different safety-touchy equipment current beginning relays are used on single-phase, fractional horsepower cars requiring low beginning torque.

Read more about the torque:

https://brainly.com/question/20691242

#SPJ1

How to remove a core plug

Answers

The ways to remove a core plug are:

Push them out. Pry itSeal it

What is the plug about?

Core plugs are known to be called freeze plugs as they are often used to fill the sand casting core holes seen inside water-cooled internal combustion engines.

Note that to do the above, one needs:

Flat tip screwdriverHammerChannel locks pliers, etc.

The ways to remove a core plug are:

Push them out. Pry itSeal it

Learn more about plug from

https://brainly.com/question/7143308

#SPJ1

Ascertain who the stakeholders in this project might be and how you will communicate the impending changes with them

Answers

Answer:

y que cierren el orto si no demuestran nada

Other Questions
How much force is needed to accelerate a 2500 kg car at a rate of 4m/s?10,000 N8,400 N625 N7,500 N Real estate suggests that 90% of homes for sale have garages (let it be an event A), 15% have swimming pools (let it be an event B), and 10% have both features: a garage and a pool. a) What is the probability that a home selected at random has at least one feature (either a garage, or a pool, or both features)? how did the old man feel about his position in life 4(x-5)=3x+7 how many solutions You have $150 to spend at a store. If you shoes cost $30 and belts cost $25, write an equation that represents the different ways that you could spend a total of $150, create a graph of the equation We are less afraid to be drowned than thou art Corey wants to use a one-sample z interval to estimate the proportion of his coworkers who drink coffee every morning. He takes an SRS of 10 of his 50 total coworkers and finds that 6 of those sampled drink coffee every morning. Which conditions for constructing this confidence interval did Corey's sample meet?Choose all answers that apply: A. The data is a random sample from the population of interest.B. [tex]np \: \geqslant 10 \: and \: n(1 - p) \geqslant 10[/tex]C. individual observation can be considered independent 3Select the correct answer.What does Shakespeare emphasize about Caesar In Marc Antony's speech? .Caesar brought wealth to the city of Rome.OB.Caesar was a very ambitious leader.OC.Caesar was disliked by the citizens of Rome.O D.Caesar did honorable things in his life. Which graph represent an exponential function (x^1/2 -x) -(2x^3 -x^1/2 - x) which inequality is graphed below Calculate the product below and give your answer in scientific notation.(1.5 10) X (2.0 10-5) = ? Which quote supports that the author developed the claim that travel narratives areworthwhile through personal and text-based examples?A. "The book taught me lessons in wilderness survival...."B. "The traveler's tale is always in the nature of a report."C."One of the first books my father read to me at bedtime when I was small was Donn Fendler: Loston a Mountain in Maine."D. "I think of the travel writer as idealized in the lines of the ghost of Hamlet's father.... Pls help Im struggling with this question. 19. An alternative has the following cash flows: $50,000 per year Benefits Disbenefits $27,000 per year Initial cost $250,000 M&O costs $10,000 per year If the alternative has an infinite life and the interest rate is 10% per year, the B/C ratio is closest to: a. 0.52 b. 0.66 e. 0.91 Use the linear combination method to solve the system of equations.2.1x + 4y = 5.32.1x 5.5y = 0.2What is the solution to the system? what is the main function of mitochondria the _____ feature enables you to represent text as colorful visuals. Fill in the blank with the correct definite article (el, la, los, las). amigamuchachas A letter to your aunt reminding her of her promise to buy you Christmas dress