Open the"stateData3.c" program and try to understand how the tokenization works. If you open the input file "stateData.txt", you can clearly seethat a comma separates the state name and its population. The tokenizer portion of the programs separates each line into two tokens and stores them into two different arrays. You need to display the arrayelements such that each line has a state and itspopulation. Also calculate the total population of USA.Then,examine the portion of the code how it writes the array elements into a binary datafile.You need to write similar logic where it writes the array elements into a text file "stateDataOutput2.txt". Please check the syntax and usage of fprintf(); and use that here.

Answers

Answer 1

Answer:

Kindly see explaination

Explanation:

Code

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define size 200

int main(void)

{

int const numStates = 50;

char tempBuffer[size];

char tmp[size];

char fileName[] = "stateData.txt"; // Name of the text file (input file) which contains states and its populations

char outFile[] = "stateDataOutput1.txt"; // Output file name

// Open the input file, quit if it fails...

FILE *instream = fopen(fileName, "r");

/* Output File variable */

FILE *opstream;

if(instream == NULL) {

fprintf(stderr, "Unable to open file: %s\n", fileName);

exit(1);

}

//TODO: Open the output file in write ("w") mode

/* Opening output file in write mode */

opstream = fopen(outFile, "w");

//TODO: Read the file, line by line and write each line into the output file

//Reading data from file

while(fgets(tmp, size, instream) != NULL)

{

//Writing data to file

fputs(tmp, opstream);

}

// Close the input file

fclose(instream);

//TODO: Close the output file

/* Closing output file */

fclose(opstream);

return 0;

}


Related Questions

Calculate the diffusion current density for the following carrier distributions. For electrons, use Dn = 35 cm2/s and for holes, use Dp = 10 cm2/s. a. ; Jn = ______________________________________________ b. , at x = 0: Jp (0) = __________________________________ c. , at x = 2.5 µm: Jp (2.5 µm) = _______________________________________ d. , at x = 20 µm: Jp (20 µm) = _______________________________________________ e. , at x = 5 µm: Jn (5 µm) = _______________________________________________ n (x) = (1010 cm−3 ) 5 μm − x 5 μm

Answers

Answer:

(a) Jn = 64.08 μA/m²

(b) Jp = 80.1 μA/m²

(c) Jp = 22.94 μA/m²

(d) Jp = 3.6357 пA/m²

(e) Jn = 22.63 μA/m²

Explanation:

See the attached file for the explanation.

a pressure vessel of 250-mm inner diameter and 6-mm wall thickness is fabricated from a 1.2-m section of spirally welded pipe AB and is equipped with two rigid end plates. the gage pressure inside the vessel is 2 MPa, and 45-kN centric axial forces P and P' are applied to the end plates. Determine a) the normal stress perpendicular to the weld b) the shearing stress parallel to the weld.

Answers

Final answer:

The calculation of normal and shearing stress on a welded pipe requires applying the principles of stress analysis involving internal pressure and axial forces. Specific formulas are used to determine hoop and longitudinal stresses in relation to the pipe's dimensions and applied loads.

Explanation:

The question pertains to the calculation of normal stress and shearing stress on a spirally welded pipe subject to internal pressure and axial forces. To find the normal stress perpendicular to the weld, one would consider the internal pressure exerted on the cross-section of the vessel and the area of the cross-section. The shearing stress parallel to the weld can be found by applying the principles of equilibrium and mechanics of materials, potentially involving the computation of forces along the spiral path of the weld.

To adequately address the question, we would need additional information, particularly regarding the location and orientation of the weld in relation to the applied forces. Without this, it is not possible to provide a detailed solution. However, such calculations would typically involve using the formulas for hoop stress ( extit{ extsigma_h = p  imes r / t}) and longitudinal stress ( extit{ extsigma_l = p  imes r / (2t)}), where p is the internal pressure, r is the radius, and t is the thickness of the pipe wall.

Consider a venture with a small hole drilled in the side of the throat. This hole is connected via a tube to a closed reservoir. The purpose of the venture is to create vacuum in the reservoir when the venture is placed in an airstream. (The vacuum is defined as the pressure difference below the outside ambient pressure.) The venture has a throat to inlet area ratio of 0.85. Calculate the maximum vacuum obtainable in the reservoir when the venturi is placed in an airstream of 90 m/s at standard sea level conditions.

Answers

Answer:

1913meter per second square.

Explanation:

From the Context the vacuum can be said be the presence of 5e difference below the outside ambient temperature.

For the Venturi.

Please go through the attached file for the rest of the solutions and the answer.

A 2-kg sphere A strikes the frictionless inclined surface of a 6-kg wedge B at a 90 degree angle with a velocity of magnitude 4 m/s. The wedge can roll freely on the ground and is initially at rest. Knowing that the coefficient of restitution between the wedge and the sphere is 0.5 and that the inclined surface of the wedge forms an angle θ=40 degrees with the horizontal, determine the velocities of the sphere and the wedge immediately after impact.

Answers

Answer:

Final velocities are:

Wedge B: v = 2.334 m/s

Sphere A: v = 5.386 m/s

Explanation:

Given:-

- The mass of sphere A,  mA = 2-kg

- The mass of the wedge B,  mB = 6-kg

- The sphere collides with " normal " to the wedge face.

- The coefficient of restitution , e = 0.5

- The wedge inclination angle, θ=40 degrees with the horizontal.

- The initial speed of sphere A, vA = 4m/s

- The initial speed of wedge B, vB = 0 m/s ... ( rest )

Find:-

- First step would be to sketch a system of sphere A and wedge B as ( FBD ).

- We will add a sketch of "two" coordinate axes on the ( FBD ).

   First coordinate system ( normal ( n ) - tangent ( t ) )

Normal axis at 90 degrees directed towards the wedge in direction of sphere motion - denote as ( n ).Tangent axis along ( parallel ) to the wedge surface directed up the wedge - denote as ( t )

    Second coordinate system ( horizontal ( x ) - vertical ( y ) )

Horizontal axis parallel to ground directed towards the right in assumed direction of wedge motion after impact - denote as ( x ).Vertical axis normal to the ground directed upwards -denote ( y ).

Note:- All the above directions of coordinate axes denote the positive direction of vectors.

- Resolve the angle ( α ) between the normal - ( n ) or velocity vector vA and the horizontal - ( x ) axis.

                               

                            α = 90° - θ = 90° - 40°

                            α = 50°  

- We will denote the final velocity components of sphere A as ( v'An , v'At ):

And, final velocity components of wedge B as ( v'B ).

- Transform the the final velocity of wedge ( vB' ) in the (n-t) coordinate axis using the resolved coordinate transformation angle ( α ). The normal  ( n ) and tangential components of the velocity vector ( vB' ) are: ( vB'n , vB't ).

                     vB'n = vB'*cos ( α )             vB't = vB'*sin ( α° )

                    vB'n = vB'*cos ( 50° )         vB't = vB'*sin ( 50° )

- Note: There is no y-component of velocity of wedge. This is because the motion of wedge in the vertical direction is restricted by the ground - equilibrium conditions. Hence, v'By = 0.

- Consider the system of sphere A and wedge B to be isolated with no external forces acting on the system. For such conditions the principle of conservation of momentum ( P ) is valid. Which states:

                        PA,i + PBi = PA,f + PB,f

Where,

           PA,i : The initial momentum of the sphere A

           PB,i : The initial momentum of wedge B

           PA,f : The final momentum of the sphere A

           PB,f : The final momentum of wedge B.

- Using the data given and relations computed in the ( n-t ) coordinate system. We will use the principle of conservation of linear momentum in both axis ( n and t ) combined in vector momentum of system.

Conservation of linear momentum:

                       

                      [tex]m_A*v_A + m_B*v_B = m_A*v_A' + m_B*v_B'[/tex]

- Using vector notations we have, Taking ( i unit vector in tangential direction and j unit vector in the normal direction ):

                       [tex]m_A*v_A_n j = m_A*( v_A'_t i + v_A'_n j )+ m_B* ( v_B'_n j + v_B'_t i )\\\\2*4 j = 2*( v_A'_t i + v_A'_n j )+ 6* ( v_B'_n j + v_B'_t i )\\\\0 i + 8 j = ( 2*v_A'_t + 6*v_B'*sin ( 50 ) ) i + ( 2*v_A'_n + 6*v_B'* cos (50 ) ) j[/tex]

- Equate all the ( i - j ) vectors on left and right hand side of the equation respectively,

               [tex]0 = 2*v_A'_t + 6*v_B'*sin ( 50 )\\\\\\ 8 = 2*v_A'_n + 6*v_B'* cos(50 )[/tex]         .... Eq 1

       

- The coefficient of restitution ( e ) is a squared loss of kinetic energy of the system that can be expressed in terms of velocities of two objects as relative change in velocity of two objects after and before impact.:

                             [tex]e = \frac{v_B'_n - v_A'_n}{v_A_n - v_B_n}[/tex]

Note: We have only used the velocities normal to the surface of wedge. This is because the kinetic loss is a scalar dimension; hence, the normal direction to the surface of impact is assumed to cater all the loss in kinetic energy.

We have,

                            [tex]0.5 = \frac{v_B'*cos ( 50 ) - v_A'_n}{ 4 - 0}\\\\2 = v_B'*cos ( 50 ) - v_A'_n \\\\v_B'*cos ( 50 ) = v_A'_n + 2[/tex]       ..... Eq 2

- Now substitute equation 2 into equation 1:

                             [tex]8 = 2*v_A'_n + 6*( v_A'_n + 2 )\\\\-4 = 8*v_A'_n\\\\v_A'_n = -0.5 \frac{m}{s}[/tex]

- Using Equation 2 compute v'B:

                 

                             [tex]v_B'*cos ( 50 ) = -0.5 + 2\\\\v_B'= \frac{1.5}{cos ( 50 ) } \\\\v_B'= 2.334 \frac{m}{s}[/tex]

- Using Equation 1 compute v'At:

                             [tex]0 = 2*v_A'_t + 6*2.334*sin ( 50 )\\\\v_A'_t = - \frac{6*2.334*sin ( 50 )}{2} \\\\v_A'_t = - 5.363 \frac{m}{s}[/tex]

- The final velocity of wedge B along the horizontal direction ( x ) is:

                          vB' = 2.334 m/s   .... x-direction

- The velocity of sphere A after impact is given by:

                             

                          [tex]v_A' = \sqrt{v_A't^2 + v_A'n^2}\\\\v_A' = \sqrt{5.363^2 + 0.5^2}\\\\v_A' = \sqrt{29.011769}\\\\v_A' = 5.386 \frac{m}{s}[/tex]

                         

                             

                   

                   

                           

     

The steel bar has a 20 x 10 mm rectangular cross section and is welded along section a-a. The weld material has a tensile yield strength of 325 MPa and a shear yield strength of 200 MPa, and the bar material has a tensile yield strength of 350 MPa. An overall factor of safety of at least 2.0 is required. Find the largest load P that can be applied, to satisfy all criteria.

Answers

Final answer:

The largest load P that can be applied to the steel bar, ensuring a factor of safety of 2.0 with respect to the weld material's tensile yield strength, is 32.5 kN. This is calculated based on the allowable tensile strength of the weld after applying the factor of safety and the cross-sectional area of the steel bar.

Explanation:

The student's question relates to the structural engineering concept of material strength and loading. The maximum load P that can be safely applied to a welded steel bar can be determined by considering the tensile and shear yield strengths of the two materials involved, i.e., the weld material and the bar material. Using the given factor of safety of 2.0, the tensile strength of the weld and the bar, and the cross section of the bar, we can calculate the allowable tensile stress and then the maximum load P by dividing the allowable tensile stress by the area of the cross section.

To begin with, we find the allowable tensile strength by dividing the weld material's yield strength (which is the weaker material concerning tensile strength) by the factor of safety:

Allowable tensile strength for weld = 325 MPa / 2 = 162.5 MPa

Next, we need to calculate the area of the cross-section of the bar:

Area (A) = 20 mm x 10 mm = 200 mm² = 200 x 10⁻⁶ m²

Now, we convert the units of the allowable tensile strength to N/m² (because 1 MPa = 1 x 10⁶ N/m²) and calculate the maximum tensile load (Ptensile) that the weld can sustain:

Allowable tensile strength for weld in N/m² = 162.5 x 10⁶ N/m²Ptensile = Allowable tensile strength for weld x AreaPtensile = (162.5 x 10⁶ N/m²) x (200 x 10⁻⁶ m²)Ptensile = 32.5 x 10³ N = 32.5 kN

Thus, the largest load P that can be applied to the steel bar to satisfy the safety criteria is 32.5 kN.

I have a signal that is experiencing 60 Hz line noise from a nearby piece of equipment, and I want to make sure that the noise is filtered out. I expect that there might be useful information at frequencies higher and lower than 60 Hz. Which would be the best type of filter for this purpose?

a. BandStop filter
b. Low-pass filter
c. Bandpass filter
d. High-pass filter

Answers

Answer:

a. BandStop filter

Explanation:

A band-stop filter or band-rejection filter is a filter that eliminates at its output all the signals that have a frequency between a lower cutoff frequency and a higher cutoff frequency. They can be implemented in various ways.  One of them is to implement a notch filter, which is characterized by rejecting a certain frequency that is interfering with a circuit. The transfer function of this filter is given by:

[tex]H(s)=\frac{s^2+\omega_o^2}{s^2+\omega_cs+\omega_o^2} \\\\Where:\\\\\omega_o=Central\hspace{3} rejected\hspace{3} frequency\\\omega_c=Width\hspace{3} of\hspace{3} the\hspace{3} rejected\hspace{3} band[/tex]

I attached you a graph in which you can see how the filter works.

A system executes a power cycle while receiving 1000 kJ by heat transfer at a temperature of 500 K and discharging 700 kJ by heat transfer at a temperature of 300 K. There are no other heat transfers. Determine the cycle efficiency. Use the Clausius Inequality to determine , in kJ/K. Determine if this cycle is internally reversible, irreversible, or impossible.

Answers

Answer:

[tex]\eta_{th} = 30\,\%[/tex], [tex]\eta_{th,max} = 40\,\%[/tex], [tex]\Delta S = \frac{1}{3}\,\frac{kJ}{K}[/tex], The cycle is irreversible.

Explanation:

The real cycle efficiency is:

[tex]\eta_{th} = \frac{1000\,kJ-700\,kJ}{1000\,kJ} \times 100\,\%[/tex]

[tex]\eta_{th} = 30\,\%[/tex]

The theoretical cycle efficiency is:

[tex]\eta_{th,max} = \frac{500\,K-300\,K}{500\,K} \times 100\,\%[/tex]

[tex]\eta_{th,max} = 40\,\%[/tex]

The reversible and real versions of the power cycle are described by the Clausius Inequalty:

Reversible Unit

[tex]\frac{1000\,kJ - 600kJ}{300\,K}= 0[/tex]

Real Unit

[tex]\Delta S = \frac{1000\,kJ-600\,kJ}{300\,K} -\frac{1000\,kJ-700\,kJ}{300\,K}[/tex]

[tex]\Delta S = \frac{1}{3}\,\frac{kJ}{K}[/tex]

The cycle is irreversible.

The cycle efficiency using clausius inequality is;

σ_cycle = 0.333 kJ/kg and is internally irreversible

For the cycle, we know that efficiency is;

η = 1 - Q_c/Q_h

Thus;

Q_c = (1 - η)Q_h

Now, the cycle efficiency is derived from the integral;

σ_cycle = -∫(dQ/dt)ₐ

Thus; σ_cycle = -[(Q_h/T_h) - (Q_c/T_c)]

We are given;

Q_h = 1000 kJ

T_h = 500 k

T_c = 300 k

Q_c = 700 kJ

Thus;

σ_cycle = -[(1000/500) - (700/300)]

σ_cycle = -(2 - 2.333)

σ_cycle = 0.333 kJ/kg

Since σ_cycle > 0, then the cycle is internally irreversible

Read more about cycle efficiency at; https://brainly.com/question/16014998

Consider a drainage basin having 60% soil group A and 40% soil group B. Five years ago the land use pattern in the basin was ½ wooded area with poor cover and ½ cultivated land (row crops/contoured and terraces) with good conservation treatment. Now the land use has been changed to 1/3 wooded area with poor cover, 1/3 cultivated land (row crops/contoured and terraces) with good conservation treatment, and 1/3 commercial and business area.

(a) Estimate the increased runoff volume during the dormant season due to the land use change over the past 5-year period for a storm of 35 cm total depth under the dry antecedent moisture condition (AMC I). This storm depth corresponds to a duration of 6-hr and 100-year return period. The total 5-day antecedent rainfall amount is 30 mm. (Note: 1 in = 25.4 mm.)
(b) Under the present watershed land use pattern, find the effective rainfall hyetograph (in cm/hr) for the following storm event using SCS method under the dry antecedent moisture condition (AMC I).

Answers

Answer:

Please see the attached file for the complete answer.

Explanation:

Steel (AISI 1010) plates of thickness δ = 6 mm and length L = 1 m on a side are conveyed from a heat treatment process and are concurrently cooled by atmospheric air of velocity u[infinity] = 10 m/s and T[infinity] = 20°C in parallel flow over the plates. For an initial plate temperature of Ti = 300°C, what is the rate of heat transfer from the plate? What is the corresponding rate of change of the plate temperature? The velocity of the air is much larger than that of the plate.

Answers

Answer:

Rate of heat transfer from plate

6796.16 W

Corresponding rate of change of plate temperature

-2634 degrees.Celcius/sec

Explanation:

In this question, we are asked to calculate the rate of heat transfer and the corresponding rate of change of the plate temperature.

Please check attachment for complete solution and step by step explanation

- Consider a 2024-T4 aluminum material with ultimate tensile strength of 70 ksi. In a given application, a component of this material is to experience ‘released tension’ stress cycling between minimum and maximum stress level of 0 and σmax ksi. As an engineer, you want to have 99.9% chance that the component does not fail before 1,000,000 cycles. What should be the value of σmax?

Answers

To have a 99.9% chance that the component does not fail before 1,000,000 cycles, the maximum stress level (σmax) should be set to 17.15 ksi or lower.

Given:

- Material: 2024-T4 aluminum

- Ultimate tensile strength: 70 ksi

- Minimum stress level: 0 ksi

- Desired reliability: 99.9% for 1,000,000 cycles

Step 1: Determine the endurance limit (σe) for the material.

For aluminum alloys, the endurance limit is typically taken as the stress level at which the S-N curve (stress vs. number of cycles to failure) becomes horizontal.

A common approximation for the endurance limit of aluminum alloys is:

σe ≈ 0.35 × Ultimate tensile strength

σe ≈ 0.35 × 70 ksi = 24.5 ksi

Step 2: Adjust the endurance limit for the desired reliability.

The endurance limit is typically determined for a reliability of 50%. To achieve a higher reliability, we need to apply a correction factor.

For a reliability of 99.9%, the correction factor is approximately 0.7.

Adjusted endurance limit = σe × 0.7 = 24.5 ksi × 0.7 = 17.15 ksi

Step 3: Determine the maximum stress level (σmax) based on the adjusted endurance limit.

For a fully reversed stress cycle (minimum stress = 0), the maximum stress level should not exceed the adjusted endurance limit.

σmax ≤ 17.15 ksi

Therefore, to have a 99.9% chance that the component does not fail before 1,000,000 cycles, the maximum stress level (σmax) should be set to 17.15 ksi or lower.

The diffusion of a molecule in a tissue is studied by measuring the uptake of labeled protein into the tissue of thickness L =8 um. Initially, there is no labeled protein in the tissue. At t=0, the tissue is placed in a solution with a molecular concentration of C1=9.4 uM, so the surface concentration at x=0 is maintained at C1. Assume the tissue can be treated as a semi-infinite medium. Surface area of the tissue is A = 4.2 cm2. Calculate the flux into the tissue at x=0 and t=5 s.Please give your answer with a unit of umol/cm2 s. Assuming the diffusion coefficient is known of D=1*10-9 cm2/s

Answers

Answer:

The flux into the tissue at x=0 and t=5 s is 0.4476 uM/cm²s

Explanation:

Flux = [tex]\frac{Quantity}{Area * Time}[/tex]

given:

Area = 4.2 cm²

Time = 5 sec

Quantity ( concentration) = 9.4 uM

∴ Flux = Quantity / (Area × Time)

Flux = 9.4 uM / (4.2 cm² × 5 s)

Flux = 9.4 uM / 21 cm²s

Flux = 0.4476 uM/cm²s

5.3-16 A professor recently received an unexpected $10 (a futile bribe attached to a test). Being the savvy investor that she is, the professor decides to invest the $10 into a savings account that earns 0.5% interest compounded monthly (6.17% APY). Furthermore, she decides to supplement this initial investment with an additional $5 deposit made every month, beginning the month immediately following her initial investment.
(a) Model the professor's savings account as a constant coefficient linear difference equation. Designate yln] as the account balance at month n, where n corresponds to the first month that interest is awarded (and that her $5 deposits begin).
(b) Determine a closed-form solution for y[n] That is, you should express yIn] as a function only of n.
(c) If we consider the professor's bank account as a system, what is the system impulse response h[n]? What is the system transfer function Hz]?
(d) Explain this fact: if the input to the professor's bank account is the everlasting exponential xn] 1 is not y[n] I"H[I]-HII]. 1, then the output

Answers

Answer:

a) y (n + 1) = 1.005 y(n) + 5U n

y (n + 1) - 1.005 y(n) = 5U (n)

b) Z^-1(Z(y0)=y(n) = [1010(1.005)^n - 1000(1)^n] U(n)

c) h(n) = (1.005)^n U(n - 1) + 10(1.005)^n U(n)

Explanation:

Her bank account can be modeled as:

y (n + 1) = y (n) + 0.5% y(n) + $5

y (n + 1) = 1.005 y(n) + 5U n

Given that y (0) = $10

y (n + 1) - 1.005 y(n) = 5U (n)

Apply Z transform on both sides

= ZY ((Z) - Z(y0) - 1.005) Z = 5 U (Z)

U(Z) = Z {U(n)} = Z/ Z - 1

Y(Z) [Z- 1.005] = Z y(0) + 5Z/ Z - 1

= 10Z/ Z - 1.005 + 5Z/(Z - 1) (Z - 1.005)

Y(Z) = 10Z/ Z - 1.005 + 1000Z/ Z - 1.005 + 1000Z/ Z - 1

= 1010Z/Z- 1.005 - 1000Z/Z-1

Apply inverse Z transform

Z^-1(Z(y0)) = y(n) = [1010(1.005)^n - 1000(1)^n] U(n)

Impulse response in output when input f(n) = S(n)

That is,

y(n + 1)= 1. 005y (n) + 8n

y(n + 1) - 1.005y (n) = 8n

Apply Z transform

ZY (Z) - Z(y0) - 1.005y(Z) = 1

HZ (Z - 1.005) = 1 + 10Z [Therefore y(Z) = H(Z)]

H(Z) = 1/ Z - 1.005 + 10Z/Z - 1. 005

Apply inverse laplace transform

= h(n) = (1.005)^n U(n - 1) + 10(1.005)^n U(n)

Air is compressed from 100 kPa, 300 K to 1000 kPa in a two-stage compressor with intercooling between stages. The intercooler pressure is 300 kPa. The air is cooled back to 300 K in the intercooler before entering the second compressor stage. Each compressor stage is isentropic. Please calculate the total compressor work per unit of mass flow (kJ/kg). Repeat for a single stage of isentropic compression from the given inlet to the final pressure.

Answers

Answer:

The total compressor work is 234.8 kJ/kg for a isentropic compression

Explanation:

Please look at the solution in the attached Word file

Final answer:

The total compressor work per unit of mass flow in a two-stage compressor with intercooling can be calculated by summing the compressor work in each stage and the work done in the intercooler.

Explanation:

The total compressor work per unit of mass flow in a two-stage compressor with intercooling can be calculated by summing the compressor work in each stage and the work done in the intercooler.

In the first stage, the air is compressed from 100 kPa to 300 kPa. The work done in this stage can be calculated using the isentropic compression process. In the second stage, the air is further compressed from 300 kPa to 1000 kPa. The work done in this stage can also be calculated using the isentropic compression process.

To calculate the total compressor work per unit of mass flow, you need to sum the work done in each stage and the work done in the intercooler.

Water containing a solute is flowing through a 1cm diameter tube, which is 50 cm in length, at an average velocity of 1 cm/s. The temperature of water is 37 C. The walls of the tube are coated with an enzyme that makes the solute disappear instantly. The solute enters the tube at a concentration of 0.1 M and the solute has a MW of 300 g/mol. Estimate the fraction of the solute that leaves the tube. Assume that the viscosity and density of water at these conditions are 0.76 cP and 1g/cm^3, respectively.

Answers

Answer:

Explanation:

See the attachment for a step by step solution to the question.

16.44 Lab 13D: Student Scores with Files and Functions Overview Create a program that reads from multiple input files and calls a user-defined function. Objectives Gain familiarity with CSV files Perform calculations with data from CSV files Create a user-defined function Read from multiple files in the same program

Answers

Answer:

See Explaination

Explanation:

# copy the function you have this is just for my convenniece

def finalGrade(scoresList):

weights = [0.05, 0.05, 0.40, 0.50]

grade = 0

for i in range(len(scoresList)):

grade += float(scoresList[i]) * weights[i]

return grade

import csv

def main():

with open('something.csv', newline='') as csvfile:

spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')

file = open('something.txt')

for row in spamreader:

student = file.readline().strip()

scores = row

print(student, finalGrade(scores))

if __name__ == "__main__":

main()

Number pattern Write a recursive method called print Pattern() to output the following number pattern. Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached.

Answers

Answer:

See explaination

Explanation:

Code;

import java.util.Scanner;

public class NumberPattern {

public static int x, count;

public static void printNumPattern(int num1, int num2) {

if (num1 > 0 && x == 0) {

System.out.print(num1 + " ");

count++;

printNumPattern(num1 - num2, num2);

} else {

x = 1;

if (count >= 0) {

System.out.print(num1 + " ");

count--;

if (count < 0) {

System.exit(0);

}

printNumPattern(num1 + num2, num2);

}

}

}

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int num1;

int num2;

num1 = scnr.nextInt();

num2 = scnr.nextInt();

printNumPattern(num1, num2);

}

}

See attachment for sample output

A recursive method in Python to output the following number pattern:

def printPattern(n, m):

 # Base case: if n is 0 or negative, return

 if n <= 0:

   return

 # Print the current number

 print(n)

 # Recursively call the function with n subtracted by m

 printPattern(n - m, m)

 # Recursively call the function with n added by m

 printPattern(n + m, m)

# Example usage:

printPattern(12, 3)

Output:

12

9

12

15

12

...

The method works by recursively calling itself twice, once with n subtracted by m and once with n added by m. This process continues until n reaches 0 or a negative value. At that point, the base case is reached and the function returns.

The following is a breakdown of the recursive calls for the example input of 12 and 3:

printPattern(12, 3)

 printPattern(9, 3)

   printPattern(6, 3)

     printPattern(3, 3)

       printPattern(0, 3)

         # Base case reached, return

       printPattern(3, 3)

     printPattern(6, 3)

   printPattern(9, 3)

 printPattern(15, 3)

   printPattern(12, 3)

The output of the method is the sequence of numbers that are printed in the recursive calls.

For such more question on Python

https://brainly.com/question/29563545

#SPJ3

An air-standard cycle with constant specific heats at room temperature is executed in a closed system with 0.003 kg of air and consists of the following three processes:

1–2 v = Constant heat addition from 95 kPa and 17°C to 380 kPa
2–3 Isentropic expansion to 95 kPa
3–1 P = Constant heat rejection to initial state

The properties of air at room temperature are cp = 1.005 kJ/kg·K, cv = 0.718 kJ/kg·K, and k = 1.4

a) Show cycle on P-v and T-s diagrams
b) Calculate net work per cycle in kJ
c) Determine thermal efficiency

Answers

Answer:

A) I attached the diagrams

B)W_net = 0.5434 KJ

C) η_th = 0.262

Explanation:

A) I've attached the P-v and T-s diagrams

B) The temperature at state 2 can be calculated from ideal gas equation at constant specific volume;

So; P2/P1 = T2/T1

Thus, T2 = P2•T1/P1

We are given that;

P2 = 380 KPa

P1 = 95 KPa

T1 = 17 °C = 17 + 273K = 290K

Thus,

T2 = (380 x 290)/95

T2 = 1160 K

While the temperature at state 3 will be gotten from;

T3 = T2 x (P3/P2)^((γ - 1)/γ)

Where γ = cp/cv = 1.005/0.718 = 1.4

Thus;

T3 = 1160 (95/380)^((1.4 - 1)/1.4)

T3 = 780.6 K

Now, net work done is given by the formula;

W_net = Q_in - Q_out

W_net = Q_1-2 - Q_3-1

W_net = m(u2 - u1) - m(h3 - h1)

W_net = m(u2 - u1 - h3 + h1)

From the first table i attached,

At T1 = 290K, u1 = 206.91 KJ/Kg and h1 = 290.16 KJ/Kg

At T2 = 1160K,u2 = 897.91 KJ/Kg

At T3 = 780K, h3 = 800.03 KJ/Kg

We are also given that m = 0.003 kg

Thus;

W_net = 0.003(897.91 - 206.91 - 800.03 + 290.16)

W_net = 0.5434 KJ

C) The thermal efficiency is given by the formula ;

η_th = W_net/Q_in

η_th = 0.5434/(m(u2 - u1))

η_th = 0.5434/(0.003(897.91 - 206.91))

η_th = 0.262

Five Kilograms of continuous boron fibers are introduced in a unidirectional orientation into of an 8kg aluminum matrix. Calculate:

a. the density of the composite.
b. the modulus of elasticity parallel to the fibers.
c. the modulus of elasticity perpendicular to the fibers.

Answers

Answer:

Explanation:

Given that,

Mass of boron fiber in unidirectional orientation

Mb = 5kg = 5000g

Mass of aluminum fiber in unidirectional orientation

Ma = 8kg = 8000g

A. Density of the composite

Applying rule of mixing

ρc = 1•ρ1 + 2•ρ2

Where

ρc = density of composite

1 = Volume fraction of Boron

ρ1 = density composite of Boron

2 = Volume fraction of Aluminum

ρ2 = density composite of Aluminum

ρ1 = 2.36 g/cm³ constant

ρ2 = 2.7 g/cm³ constant

To Calculate fractional volume of Boron

1 = Vb / ( Vb + Va)

Vb = Volume of boron

Va = Volume of aluminium

Also

To Calculate fraction volume of aluminum

2= Va / ( Vb + Va)

So, we need to get Va and Vb

From density formula

density = mass / Volume

ρ1 = Mb / Vb

Vb = Mb / ρ1

Vb = 5000 / 2.36

Vb = 2118.64 cm³

Also ρ2 = Ma / Va

Va = Ma / ρ2

Va = 8000 / 2.7

Va = 2962.96 cm³

So,

1 = Vb / ( Vb + Va)

1 = 2118.64 / ( 2118.64 + 2962.96)

1 = 0.417

Also,

2= Va / ( Vb + Va)

2 = 2962.96 / ( 2118.64 + 2962.96)

2 = 0.583

Then, we have all the data needed

ρc = 1•ρ1 + 2•ρ2

ρc = 0.417 × 2.36 + 0.583 × 2.7

ρc = 2.56 g/cm³

The density of the composite is 2.56g/cm³

B. Modulus of elasticity parallel to the fibers

Modulus of elasticity is defined at the ratio of shear stress to shear strain

The relation for modulus of elasticity is given as

Ec = = 1•Eb+ 2•Ea

Ea = Elasticity of aluminium

Eb = Elasticity of Boron

Ec = Modulus of elasticity parallel to the fiber

Where modulus of elastic of aluminum is

Ea = 69 × 10³ MPa

Modulus of elastic of boron is

Eb = 450 × 10³ Mpa

Then,

Ec = = 1•Eb+ 2•Ea

Ec = 0.417 × 450 × 10³ + 0.583 × 69 × 10³

Ec = 227.877 × 10³ MPa

Ec ≈ 228 × 10³ MPa

The Modulus of elasticity parallel to the fiber is 227.877 × 10³MPa

OR Ec = 227.877 GPa

Ec ≈ 228GPa

C. modulus of elasticity perpendicular to the fibers?

The relation of modulus of elasticity perpendicular to the fibers is

1 / Ec = 1 / Eb+ 2 / Ea

1 / Ec = 0.417 / 450 × 10³ + 0.583 / 69 × 10³

1 / Ec = 9.267 × 10^-7 + 8.449 ×10^-6

1 / Ec = 9.376 × 10^-6

Taking reciprocal

Ec = 106.66 × 10^3 Mpa

Ec ≈ 107 × 10^3 MPa

Note that the unit of Modulus has been in MPa,

A PMDC machine is measured to va120Vdc, ia 5.5A at the electrical terminals and the shaft is measured to have Tmech 5.5Nm, ns1200RPM. State whether the machine acting as a motor or a generator and state the efficiency of the system. Q11. Motor, 89.4 %(a) Generator, 89.4%(b) Motor, 95.5%(c) Generator, 95.5 %(d) none of the abov

Answers

Answer:

(c) Generator, 95.5 %

Explanation:

given data

voltage va = 120V

current Ia = - 5.5 A

Tmech =  5.5Nm

ns = 1200 RPM

solution

first we get here electric input power that is express as

electric input power = va × Ia    ......1

put here value and we get

electric input power = 120 × -5-5

electric input power -660 W

here negative mean it generate power

and here

Pin ( mech) will be

Pin ( mech) = Tl × ω   .........2

Pin ( mech) = 5.5 × [tex]\frac{2\pi N}{60}[/tex]    

Pin ( mech) =  5.5 × [tex]\frac{2\pi 1200}{60}[/tex]  

Pin ( mech) = 691.150 W

and

efficiency will be here as

efficiency = [tex]\frac{660}{691.150}[/tex]    

efficiency = 95.5 %

so correct option is (c) Generator, 95.5 %

Steam enters a counterflow heat exchanger operating at steady state at 0.07 MPa with a quality of 0.9 and exits at the same pressure as saturated liquid. The steam mass flow rate is 1.5 kg/min. A separate stream of air with a mass flow rate of 100 kg/min enters at 30°C and exits at 60°C. The ideal gas model with 1.005 kJ/kg · K can be assumed for air. Kinetic and potential energy effects are negligible. Determine the temperature of the entering steam, in °C, and for the overall heat exchanger as the control volume, what is the rate of heat transfer, in kW.

Answers

Answer:

1.12kw is the heat transfer

Explanation:

Kinetic energy is the energy an object has because of its motion. If we want to accelerate an object, then we must apply a force.

Potential energy, stored energy that depends upon the relative position of various parts of a system.

See attachment for the step by step solution.

A solid circular shaft has a uniform diameter of 5 cm and is 4 m long. At its midpoint 65 hp is delivered to the shaft by means of a belt passing over a pulley. This power is used to drive two machines, one at the left end of the shaft consuming 25 hp and one at the right end consuming the remaining 40 hp. Determine:

a) The maximum shearing stress in the shaft.
b) The relative angle of twist between the two extreme ends of the shaft. The shaft turns at 200 rpm and the material is steel for which G = 80 GPa.

Answers

Answer:

A) τ_max = 59.139 x 10^(6) Pa

B) θ = 0.0228 rad.

Explanation:

A) In the left half of the shaft we have 25 hp which corresponds to a torque T1 given by;

P = Tω

Where P is power and ω is angular speed.

Power = 25 HP = 25 x 746 W = 18650W

ω = 200 rev/min = 200 x 0.10472 rad/s = 20.944 rad/s

P = T1•ω

T1 = P/ω = 18650/20.944

T1 = 890.47 N.m

Similarly, in the right half we have 40 hp corresponding to a torque T2

given by;

P = T2•ω

T2 = P/ω

Where P = 40 x 760 = 30,400W

T2 = 30400/20.944 = 1451.49 N.m

The maximum shearing stress consequently occurs in the outer fibers in the right half and is given by;

τ_max = Tρ/J

Where J is polar moment of inertia and has the formula ;J = πd⁴/32

d = 5cm = 0.05m

J = π(0.05)⁴/32 = 6.136 x 10^(-7) m⁴

ρ = 0.05/2 = 0.025m

T will be T2 = 1451.49 N.m

Thus,

τ_max = Tρ/J

τ_max = 1451.49 x 0.025/6.136 x 10^(-7)

τ_max = 59139022.94 N/m² = 59.139 x 10^(6) Pa

B) The angles of twist of the left and right ends relative to the center are, respectively, using θ = TL/GJ

G = 80 Gpa = 80 x 10^(9) Pa

θ1 = (890.47 x 2)/(80 x 10^(9) x 6.136 x 10^(-7)) = 0.0363 rad

Similarly;

θ2 = (1451.49 x 2)/(80 x 10^(9) x 6.136 x 10^(-7)) = 0.0591 rad

Since θ1 and θ2 are in the same direction, the relative angle of twist between the two ends of the shaft is

θ = θ2 – θ1

θ = 0.0591 - 0.0363

θ = 0.0228 rad.

The fully corrected endurance strength for a steel rotating shaft is 42 kpsi, the ultimate tensile strength is 120 kpsi, the yield strength Sy=65 kpsi, and the fatigue stress correction factor Kf = 1.96. The maximum bending stress is 43 kpsi and the minimum stress is 0 kpsi. What is the factor of safety against first-cycle-yielding?

Answers

Answer:

The factor of safety is 1.186

Explanation:

Find the attachment

Consider an aluminum step shaft. The area of section AB and BC as well as CD are 0.1 inch2 , 0.15 inch 2 and 0.20 inch2. The length of section AB, BC and CD are 10 inch, 12 inch and 16 inch. A force F=1000 lbf is applied to B. The initial gap between D and rigid wall is 0.002. Using analytical approach, determine the wall reactions, the internal forces in members, and the displacement of B and C. Find the strain in AB, BC and CD.

Answers

Answer:

Explanation:

Find attach the solution

A preheater involves the use of condensing steam at 100o C on the inside of a bank of tubes to heat air that enters at I atm and 25o C. The air moves at 5 m/s in cross flow over the tubes. Each tube is 1 m long and has an outside diameter of 10 mm. The bank consists of 196 tubes in a square, aligned array for which ST = SL = 15 mm. What is the total rate of heat transfer to the air? What is the pressure drop associated with the airflow?

(b) Repeat the analysis of part (a), but assume that the tubes have a staggered arrangement with ST = 15 mm and SL = 10 mm.

Answers

Answer:

Please see the attached file for the complete answer.

Explanation:

A relatively nonvolatile hydrocarbon oil contains 4.0 mol % propane and is being stripped by direct superheated steam in a stripping tray tower to reduce the propane content to 0.2%. The temperature is held constant at 422 K by internal heating in the tower at 2.026 × 105 Pa pressure. A total of 11.42 kg mol of direct steam is used for 300 kg mol of total entering liquid. The vapor–liquid equilibria can be represented by y = 25x, where y is mole fraction propane in the steam and x is mole fraction propane in the oil. Steam can be considered as an inert gas and will not condense. Plot the operating and equilibrium lines and determine the number of theoretical trays needed.

Answers

Answer:

Number of Trays = Six (6)

Explanation:

Given that: y' = 25x' , in terms of molecular ratio, we can write it as

[tex]\frac{Y'}{1 + Y'} =25 \frac{X'}{1 + X'}[/tex]  ......... 1

after plotting this we get equilibrium curve as shown in the attached picture.

inlet concentration and outlet concentration of liquid phase is

x₂ = 4% = 0.04 (inlet)

so that can be converted into molar

[tex]X_2 = \frac{x_2}{1-x_2} = \frac{0.04}{1-0.04} = 0.04167[/tex]

and

x₁ = 0.2% = 0.002

[tex]X_1 = \frac{x_1}{1-x_1} = \frac{0.002}{1-0.002} = 2.004*10^{-3}[/tex]

Now we have to use the balance equation a

[tex]\frac{G_s}{L_s} = \frac{X_2-X_1}{Y_2-Y_1}[/tex] .............. a

here amount of solute is comparably lower than

Here we have

L = 300 kmol (total)

[tex]L_s[/tex] = 300(1 - 0.04) = 288 kmol pure oil

G = [tex]G_s[/tex] = 11.42 kmol

[tex]Y_1[/tex] = 0 , solvent free steam

substitute into the equation a

[tex]\frac{11.42}{288} = \frac{0.04167 - 2*10^{-3}}{Y_2 - 0}[/tex]

Y₂ = 1.0003

Now plot the point A(X₁ , Y₁) and B(X₂ , Y₂) and join them to construct operating line AB.

Starting from point B, stretch horizontal line up to equilibrium curve and from there again go down to operating line as shown in the picture attached. This procedure give one count of tray and continue the same procedure up to end of operating.

at last count, the number of stage, gives 6.

Number of trays = 6

The number of theoretical trays needed is 20.

From the given data,

Equilibrium relation

y = 25x

[tex]L_s=L_2(1-x_2)\\L_s=300(1-0.04)= 288Kmol[/tex]

Applying total balance equation

[tex]G_sy_1+L_sx_2=G_sy_2+L_sx_1\\G_s(y_1-y_2)=L_s(x_1-x_2)\\x_1=\frac{0.002}{1-0.002}\\x_1=0.002\\y_1=0, y_2=?\\x_2=\frac{0.04}{1-0.04}; x_2=0.0417[/tex]

substituting the values into the equation;

[tex]11.42(0-y_2)=288(0.002-0.0417)\\0-11.42y_2=-11.4048\\y_2=0.998[/tex]

The numbers of trays

[tex]N=\frac{In[(\frac{(x_2-y_1)/m}{(x_1-y_1)/m}(1-A)+A }{In(1/A)}\\[/tex]

But [tex]A=\frac{L_s}{mGs}[/tex]

[tex]N=\frac{x_2-x_1}{(x_1-y_1)/m}=\frac{0.0417-0.002}{0.002}\\N=19.85[/tex]

The numbers of tray is approximately 20.

learn more about steam stripping and numbers of tray here

https://brainly.com/question/9349349

More discussion about seriesConnect(Ohm) function In your main(), first, construct the first circuit object, called ckt1, using the class defined above. Use a loop to call setOneResistance() function to populate several resistors. Repeat the process for another circuit called ckt2. Develop a member function called seriesConnect() such that ckt2 can be connected to ckt1 using instruction ckt1.seriesConnect(ckt2).

Answers

Answer:

resistor.h

//circuit class template

#ifndef TEST_H

#define TEST_H

#include<iostream>

#include<string>

#include<vector>

#include<cstdlib>

#include<ctime>

#include<cmath>

using namespace std;

//Node for a resistor

struct node {

  string name;

  double resistance;

  double voltage_across;

  double power_across;

};

//Create a class Ohms

class Ohms {

//Attributes of class

private:

  vector<node> resistors;

  double voltage;

  double current;

//Member functions

public:

  //Default constructor

  Ohms();

  //Parameterized constructor

  Ohms(double);

  //Mutator for volatage

  void setVoltage(double);

  //Set a resistance

  bool setOneResistance(string, double);

  //Accessor for voltage

  double getVoltage();

  //Accessor for current

  double getCurrent();

  //Accessor for a resistor

  vector<node> getNode();

  //Sum of resistance

  double sumResist();

  //Calculate current

  bool calcCurrent();

  //Calculate voltage across

  bool calcVoltageAcross();

  //Calculate power across

  bool calcPowerAcross();

  //Calculate total power

  double calcTotalPower();

  //Display total

  void displayTotal();

  //Series connect check

  bool seriesConnect(Ohms);

  //Series connect check

  bool seriesConnect(vector<Ohms>&);

  //Overload operator

  bool operator<(Ohms);

};

#endif // !TEST_H

resistor.cpp

//Implementation of resistor.h

#include "resistor.h"

//Default constructor,set voltage 0

Ohms::Ohms() {

  voltage = 0;

}

//Parameterized constructor, set voltage as passed voltage

Ohms::Ohms(double volt) {

  voltage = volt;

}

//Mutator for volatage,set voltage as passed voltage

void Ohms::setVoltage(double volt) {

  voltage = volt;

}

//Set a resistance

bool Ohms::setOneResistance(string name, double resistance) {

  if (resistance <= 0){

      return false;

  }

  node n;

  n.name = name;

  n.resistance = resistance;

  resistors.push_back(n);

  return true;

}

//Accessor for voltage

double Ohms::getVoltage() {

  return voltage;

}

//Accessor for current

double Ohms::getCurrent() {

  return current;

}

//Accessor for a resistor

vector<node> Ohms::getNode() {

  return resistors;

}

//Sum of resistance

double Ohms::sumResist() {

  double total = 0;

  for (int i = 0; i < resistors.size(); i++) {

      total += resistors[i].resistance;

  }

  return total;

}

//Calculate current

bool Ohms::calcCurrent() {

  if (voltage <= 0 || resistors.size() == 0) {

      return false;

  }

  current = voltage / sumResist();

  return true;

}

//Calculate voltage across

bool Ohms::calcVoltageAcross() {

  if (voltage <= 0 || resistors.size() == 0) {

      return false;

  }

  double voltAcross = 0;

  for (int i = 0; i < resistors.size(); i++) {

      voltAcross += resistors[i].voltage_across;

  }

  return true;

}

//Calculate power across

bool Ohms::calcPowerAcross() {

  if (voltage <= 0 || resistors.size() == 0) {

      return false;

  }

  double powerAcross = 0;

  for (int i = 0; i < resistors.size(); i++) {

      powerAcross += resistors[i].power_across;

  }

  return true;

}

//Calculate total power

double Ohms::calcTotalPower() {

  calcCurrent();

  return voltage * current;

}

//Display total

void Ohms::displayTotal() {

  for (int i = 0; i < resistors.size(); i++) {

      cout << "ResistorName: " << resistors[i].name << ", Resistance: " << resistors[i].resistance

          << ", Voltage_Across: " << resistors[i].voltage_across << ", Power_Across: " << resistors[i].power_across << endl;

  }

}

//Series connect check

bool Ohms::seriesConnect(Ohms ohms) {

  if (ohms.getNode().size() == 0) {

      return false;

  }

  vector<node> temp = ohms.getNode();

  for (int i = 0; i < temp.size(); i++) {

      this->resistors.push_back(temp[i]);

  }

  return true;

}

//Series connect check

bool Ohms::seriesConnect(vector<Ohms>&ohms) {

  if (ohms.size() == 0) {

      return false;

  }

  for (int i = 0; i < ohms.size(); i++) {

      this->seriesConnect(ohms[i]);

  }

  return true;

}

//Overload operator

bool Ohms::operator<(Ohms ohms) {

  if (ohms.getNode().size() == 0) {

      return false;

  }

  if (this->sumResist() < ohms.sumResist()) {

      return true;

  }

  return false;

}

main.cpp

#include "resistor.h"

int main()

{

   //Set circuit voltage

  Ohms ckt1(100);

  //Loop to set resistors in circuit

  int i = 0;

  string name;

  double resistance;

  while (i < 3) {

      cout << "Enter resistor name: ";

      cin >> name;

      cout << "Enter resistance of circuit: ";

      cin >> resistance;

      //Set one resistance

      ckt1.setOneResistance(name, resistance);

      cin.ignore();

      i++;

  }

  //calculate totalpower and power consumption

  cout << "Total power consumption = " << ckt1.calcTotalPower() << endl;

  return 0;

}

Output

Enter resistor name: R1

Enter resistance of circuit: 2.5

Enter resistor name: R2

Enter resistance of circuit: 1.6

Enter resistor name: R3

Enter resistance of circuit: 1.2

Total power consumption = 1886.79

Explanation:

Note

Please add all member function details.Its difficult to figure out what each function meant to be.

A pump is used to deliver water from a lake to an elevated storage tank. The pipe network consists of 1,800 ft (equivalent length) of 8-in. pipe (Hazen-Williams roughness coefficient = 120). Ignore minor losses. The pump discharge rate is 600 gpm. The friction loss (ft) is most nearly Group of answer choicesA. 15
B. 33
C. 106
D. 135

Answers

Answer:

h_f = 15 ft, so option A is correct

Explanation:

The formula for head loss is given by;

h_f = [10.44•L•Q^(1.85)]/(C^(1.85))•D^(4.8655))

Where;

h_f is head loss due to friction in ft

L is length of pipe in ft

Q is flow rate of water in gpm

C is hazen Williams constant

D is diameter of pipe in inches

We are given;

L = 1,800 ft

Q = 600 gpm

C = 120

D = 8 inches

So, plugging in these values into the equation, we have;

h_f = [10.44*1800*600^(1.85)]/(120^(1.85))*8^(4.8655))

h_f = 14.896 ft.

So, h_f is approximately 15 ft

For the first option your program should then ask the user for which row and column in the array to replace, and what value will it be replaced with. For the second option your program should run through all values held in the 2D array and calculate their summation. For the third option your program should print out the contents of the 2D array one row at a time. When given the fourth option your program should simply exit.

Answers

Answer:

#Data section

.data

#Set align

.align 2

#Declare row 1

M1: .word 1, 2, 3

#Declare row 2 elements

M2: .word 4, 5, 6

#Declare row 3 elements

M3: .word 7, 8, 9

#Declare row 4 elements

M4: .word 10, 11, 12

#Declare row 5 elements

M5: .word 13, 14, 15

#Create 5x3 array

M: .word M1, M2, M3, M4, M5

#Set number of rows

nRows: .word 5

#Set number of columns

nCols: .word 3

#Declare string menu

menu: .asciiz "\n The following are the choices:\n"

#Declare string for option 1

op1: .asciiz "1. Replace a value:\n"

#Define string for option 2

op2: .asciiz "2. Calculate the sum of all values\n"

#Define string for option 3

op3: .asciiz "3. Print out the 2D array \n"

#Define string for option 4

op4: .asciiz "4. Exit\n"

#Define string for prompt

urOpt: .asciiz "Enter your option:"

#Define string for row

prompt1: .asciiz "Enter row (1-5):"

#Define string for column input

prompt2: .asciiz "Enter column (1-3):"

#Define string to get the replace value

getVal: .asciiz "Enter the new value:"

#Define strinct to display sum

sumStr: .asciiz "\nThe sum is :"

#Define string

dispStr: .asciiz "The 2D array is:\n"

#Define string to print new line

newLine: .asciiz "\n"

#Define string to put comma

comma: .asciiz ","

#text section

.text

#Main

main:

#Block prints the 2D array

#label

print2DArray:

#Load integer to print string in $v0

li $v0, 4

#Load the address of string to display

la $a0, dispStr

#Display the string

syscall

#Load the base address of the row 1

la $s0, M1

#Load the nRows

lw $t0, nRows

#Initialize the counter for outer loop

li $t7, 0

#Outer loop begins

outLoop1:

#Check condition

beq $t7, $t0, displayMenu

#Load the integer to print string

li $v0, 4

#Load the base address of newLine

la $a0, newLine

#Display newLine

syscall

#Initialize counter for inner loop

li $t2, 0

#Set the limit

lw $t3, nCols

#Decrement value

addi $t3, $t3, -1

#inner loop starts

inLoop1:

#Check condition

beq $t2, $t3, exitInLoop1

#Load the integer to print number

li $v0, 1

#Load the value

lw $a0, ($s0)

#Display the integer

syscall

#Load the integer to print string

li $v0, 4

#Load the base address of the string comma to display

la $a0, comma

#Display comma

syscall

#Increment inner loop counter value

addi $t2, $t2, 1

#Move to next element

addi $s0, $s0, 4

#jump to inner loop

j inLoop1

#Exit from inner loop

exitInLoop1:

#Load integer to print last column value

li $v0, 1

#Load the load column value

lw $a0, ($s0)

#Print value

syscall

#Move to next element

addi $s0, $s0, 4

#Increment outer loop counter

addi $t7, $t7, 1

#Jump to start of the outer loop

j outLoop1

#Prints the menus to the user

displayMenu:

#Load integer value to print string

li $v0, 4

#Load the address of the string "menu"

la $a0, menu

#Print the string

syscall

#Load the integer value to print string

li $v0, 4

#Load the address

la $a0, op1

#Print the string

syscall

#Load the integer value to print string

li $v0, 4

#Load the address

la $a0, op2

#Print string

syscall

#Load integer value to print string

li $v0, 4

#Load address of op3

la $a0, op3

#Print string

syscall

#Load integer value to print string

li $v0, 4

#Load the address

la $a0, op4

#Print string

syscall

#Load integer value to print sting

li $v0, 4

#Load address

la $a0, urOpt

#Print string

syscall

#Load the integer to read int value

li $v0, 5

#Read value

syscall

#Move value

move $t0, $v0

#Initialize values

li $t1, 1

li $t2, 2

li $t3, 3

li $t4, 4

#Check user wishes option 1

beq $t0, $t1, replaceBlock

#Check user wishes option 2

beq $t0, $t2, sumBlock

#Check user wishes option 3

beq $t0, $t3, print2DArray

#Check user wishes to exit

beq $t0, $t4, EndProgram

#Jump to start of the menu

j displayMenu

#Block to replace a value in the 2d array

replaceBlock:

#Load integer

li $v0, 4

#load address

la $a0, prompt1

#Print string

syscall

#Read row value

li $v0, 5

syscall

#Store the row value in $t6

move $t6, $v0

#Get the index

addi $t6, $t6, -1

#Load integer

li $v0, 4

#Load address

la $a0, prompt2

#Print string

syscall

#Read column value

li $v0, 5

syscall

#Store the column value in $t7

move $t7, $v0

#Get the index for the column

addi $t7, $t7, -1

#Load integer

li $v0, 4

#Load address

la $a0, getVal

#Print string

syscall

#Read the new value

li $v0, 5

syscall

#Store the new value in $t5

move $t5, $v0

#Load the base address of M

la $s0, M

#Get M[i]

#two times left shift

sll $t1, $t6, 2

#address of pointer M[i]

add $t1, $t1, $s0

#Get address of M[i]

lw $t3, ($t1)

#Get M[i][j]

#two times left shift

sll $t4, $t7, 2

#Get address of M[i][j]

add $t4, $t3, $t4

Explanation:

See continuation of the code attached

also, See output attached

Consider a turbojet mounted on a stationary test stand at sea level. The inlet and exit areas are the same, both equal to 0.45 m^2. The velocity, pressure and temperature of the exhaust gas are 400 m/s, 1.0 ATM and 750K, respectively. Calculate the static thrust of the engine. (Note: Static thrust of a jet engine is the thrust produced when the engine has no forward motion.

Answers

Answer:

The static thrust of the engine is 20,856.44N

Explanation:

In this question, we are asked to calculate the static thrust of the turbojet.

Please check attachment for complete solution and step by step explanation

A turbojet aircraft is flying with a velocity of 280 m/s at an altitude of 9150 m, where the ambient conditions are 32 kPa and -32C. The pressure ratio across the compressor is 12, and the temperature at the turbine inlet is 1100 K. Air enters the compressor at a rate of 50 kg/s, and the jet fuel has a heating value of 42,700 kJ/kg. Assume constant specific heats for air at room temperature. Efficiency of the compressor is 80%, efficiency of the turbine is 85%. Assume air leaves diffuser with negligibly small velocity.
determine
(a) The velocity of the exhaust gases.
(b) The rate of fuel consumption.

Answers

Answer:

(a) The velocity of the exhaust gases. is 832.7 m/s

(b) The rate of fuel consumption is 0.6243 kg/s

Explanation:

For the given turbojet engine operating on an ideal cycle, the pressure ,temperature, velocity, and specific enthalpy of air at [tex]i^{th}[/tex] state are [tex]P_i[/tex] , [tex]T_i[/tex] , [tex]V_i[/tex] , and [tex]h_i[/tex] , respectively.

Use "ideal-gas specific heats of various common gases" to find the properties of air at room temperature.

Specific heat at constant pressure, [tex]c_p[/tex] = 1.005 kJ/kg.K

Specific heat ratio, k = 1.4

Other Questions
Two files named numbers1.txt and numbers2.txt both have an unknown number of lines, each line consisting of a single positive integer. Write some code that reads a line from one file and then a line from the other file. The two integers are multiplied together and their product is added to a variable called scalar_product which should be initialized to zero. Your code should stop when it detects end of file in either file that it is reading. For example, if the sequence of integers in one file was "9 7 5 18 13 2 22 16" and "4 7 8 2" in the other file, your code would compute: 4*9 + 7*7 + 8*5 + 2*18 and thus store 161 into scalar_product. The tub of a washer goes into its spin-dry cycle, starting from rest and reaching an angular speed of 2.0 rev/s in 10.0 s. At this point, the person doing the laundry opens the lid, and a safety switch turns off the washer. The tub slows to rest in 12.0 s. Through how many revolutions does the tub turn during this 22 s interval? Assume constant angular acceleration while it is starting and stopping. 5. A(n).is a long poem that tells the adventures of a brave hero.A. epicB. fableC. mythD. drama Andrew Jackson was the first president to forcefully assert the idea that the president rather than Congress should take the lead on national policy issues. the United States should align itself with France rather than Britain. the Congress needed to take responsibility for carrying out foreign policy. the United States should align itself with Britain rather than France. Come up with a plan for avoiding an asteroids collision with Earth. Write a paragraph ( 5-6 sentences) to explain how your plan would work. Please Help! Floral displays should include only the highest quality flowers, plants and other products. TRUE or FALSE? PLZ HELPThe pickup truck pulled up to the driveway. Dust and dirt seemed to billow in the air around the flatbed. The truck suddenly stopped rumbling and became perfectly still. Papas seat creaked and the door rattled open. I saw his cowboy boots jump to the ground beneath the open door. Hes here, I thought. Finally!The words creaked and rattled allow the reader to visualizehow the truck comes to a sudden stop.how old the fathers truck is.how the dust rises behind the truck.how the truck pulls into the driveway. help please!, i need help Dan is gliding on his skateboard at 3.00 m/s. He suddenly jumps backward off the skateboard, kicking the skateboard forward at 8.00 m/s. Dan's mass is 70.0 kg and the skateboard's mass is 6.00 kg. How fast is Dan going as his feet hit the ground? Bob bought a desktop computer and a laptop computer. Before finance charges, the laptop cost $300 less than the desktop. He paid for the computers using two different financing plans. For the desktop the interest rate was 7% per year, and for the laptop it was 6% per year. The total finance charges for one year were $398. How much did each computer cost before finance charges? Evaluate and simplify the expression when x=1 and y=2. 3(+2y)-2x+10=? characterization refers to the ____ presentation of characters Susan threw away in the garbage an old chair that had been in her family for many years by placing it on the curb with the rest of the trash. alma came by and began to admire the chair. although the chair was heavy, alma picked it up and called to a friend saying that she had just found an antique chair. when susan heard this, she demanded the return of the chair. the chair belongs to: susan unless alma can show susan gave it to her. susan because there was no intent to make a gift. alma because anything one finds belongs to the finder. alma because susan abandoned it and alma took possession of it. A 22-year-old male is being discharged home after surgery for testicular cancer. The patient is scheduled to begin chemotherapy in 2 weeks. The patient tells the nurse that he doesn't think he can take weeks or months of chemotherapy, stating that he has researched the adverse effects online. What is the most appropriate nursing action for this patient at this time?A) Provide empathy and encouragement in an effort to foster a positive outlook.B) Tell the patient it is his decision whether to accept or reject chemotherapy.C) Report the patient's statement to members of his support system.D) Refer the patient to social work. The radius of a cylinder is 3 cm and the height is 6 cm.Find the Surface Area. (hint: Use the answer from the previous question.) PLEASE HURRY TIMED (20 POINTS) Read the excerpt from "The Role of Social Media in the Arab Uprisings" by Heather Brown, Emily Guskin, and Amy Mitchell.Twit ter, Face book and other new media offer ways for the ArabAmerican news media to reach audiences, but also pose a threat to smaller outlets. In addition to keeping up with the online presence of larger news organizations, ArabAmerican media are forced to compete with user-generated content that is rapidly available to audiences. The utility of social media in accessing information became clear during the Arab uprisings and events such as Egypts parliamentary and presidential elections. However, [Suzanne] Manneh of New America Media points out that the credibility of this information is difficult to verify "depending on where its from, to whom its attributed, [and] especially when various events are happening very quickly."Arab-American news outlets find they must compete with this abundance of online content in order to evolve alongside readers who are increasingly turning to the internet for information. Newspapers have made the greatest inroads here so far, with most offering at least some form of digital content, while still maintaining print versions for older generations and those who prefer a physical newspaper. Radio programs, in light of the continuing challenge to find advertising sponsorship, are beginning to shift online. Arab-American television, on the other hand, has yet to even really find a place amid the satellite programming available from Arab countries.Which statements best evaluate the evidence in this excerpt? Select two options.1.The authors use a personal story to illustrate the argument that, despite new and ever-changing forms of social media, Arab American print and broadcast media are stronger than ever. 2.The authors use data about the types and effectiveness of social media to support the argument that social media is driving Arab American broadcast media out of business.3.The authors use a quotation from an expert to support the argument that social media has been both helpful and hazardous for the Arab American news media.4.The authors use a quotation from an eyewitness to support the argument that the Arab American news media face different challenges than smaller news media outlets in Arab countries.5.The authors use examples of different types of media to support the argument that social media has changed how the Arab American news media operate. The beginning of ventricular systole is when blood flowing back toward the relaxed ventricles causes the semilunar valves to close.The beginning of ventricular systole is when blood flowing back toward the relaxed ventricles causes the semilunar valves to close.A) TrueB) False Wadhams Snow Removal's cost formula for its vehicle operating cost is $1,900 per month plus $430 per snow-day. For the month of December, the company planned for activity of 16 snow-days, but the actual level of activity was 21 snow-days. The actual vehicle operating cost for the month was $11,470. Required:1. The vehicle operating cost in the planning budget for December would be closest to _________. How do creation myths differ from nature myths Why do you think some people does not enjoy their work?