Bartleby Sitemap - Textbook Solutions

All Textbook Solutions for C++ for Engineers and Scientists

(Practice) a. To convert inches (in) to feet (ft), the number of inches should be multiplied by which of the following conversion factors? i. 12 in/1 ft ii. 1 ft/12 in b. To convert feet (ft) to meters (m), the number of feet should be multiplied by which of the following conversion factors? i. 1 m/3.28 ft ii. 3.28 ft/1 m c. To convert sq.yd to sq.ft, the number of sq.yd should be multiplied by which of the following conversion factors? i. 1 sq.yd/9 sq.ft ii. 9 sq.ft/1 sq.yd d. To convert meters (m) to kilometers (km), the number of meters should be multiplied by which of the following conversion factors? i. 1000 m/1 km ii. 1 km/1000 m e. To convert sq.in to sq.ft, the number of sq.in should be multiplied by which of the following conversion factors? i. 144 sq.in/1 sq.ft ii. 1 sq.ft/144 sq.in f. To convert minutes (min) to seconds (sec), the number of minutes should be multiplied by which of the following conversion factors? i. 60 sec/1 min ii. 1 min/60 sec g. To convert seconds (sec) to minutes (min), the number of seconds should be multiplied by which of the following conversion factors? i. 60 sec/1 min ii. 1 min/60 sec(Conversion) Blood pressure is the force of blood circulating against the inner wall of blood vessels. It’s measured by two numbers: a systolic number that measures the pressure when the heart is contracting and a diastolic number that measures the pressure when the heart is resting. Both pressures are typically measured in millimeters of mercury (mm Hg) and given assystolic/diastolic numbers, such as 122/88. The National Heart, Blood, and Lung Institute provides the following guidelines for normal and high blood pressure measurements. Complete the chart by converting the measurements to atm and psi units.3E4E(Practice) a. Determine the conversion factors that can be used to convert miles per gallon (mpg=mi/gal)tokilometersperliter(km/liter),giventhat1liter=0.22gallonsand1kilometer=0.6214miles. b. Using the conversion factors you determined in Exercise 5a, convert 25 mpg into km/liter.6E(Automotive) a. An automobile engine’s performance can be determined by monitoring its rotations per minute (rpm). Determine the conversion factors that can be used to convert rpm to frequency in hertz (Hz), given that 1rotation=1cycle,1minute=60seconds,and1Hz=1cycle/sec. b. Using the conversion factors you determined in Exercise 7a, convert 2000 rpm into hertz.(Chemistry) a. Determine the final units of the following expression, which provides the molecular weight of 1.5 moles of hydrogen peroxide: 1.5moles34.0146grams/mole b. Determine the final units of the following expression, which provides the molecular weight of 5.3 moles of water: 5.3moles18grams/mole(Oceanography) The pressure, P, exerted on an underwater object can be determined by this formula: P=gh is the density of water, which is 1.94slug/ft3 . g is the acceleration caused by Earth’s gravity, which is 32.2ft/sec2. h is the object’s depth in the water in feet. a. Determine the units of P by calculating the units resulting from the right side of the formula. Check that your answer corresponds to the units for pressure listed in Table 1.1. b. Determine the pressure on a submarine operating at a depth of 2500 feet.(Thermodynamics) The work, W, performed by a single piston in an engine can be determined by this formula: W=Fd F is the force provided by the piston in Newtons. d is the distance the piston moves in meters. a. Determine the units of W by calculating the units resulting from the right side of the formula. Check that your answer corresponds to the units for work listed in Table 1.1. b. Determine the work performed by a piston that provides a force of 1000 N over a distance of 15 centimeters.(Practice) Convert the following numbers from exponential form into standard decimal form: a.6.34e5b.1.95162e2c.8.395e1d.2.95e3e.4.623e42E3E4E5E6E7E(Electrical eng.) You’ve been asked to write a C++ program to calculate the total resistance of a series circuit. In this circuit, the total resistance is the sum of all individual resistance values. The circuit consists of a number of 56-ohm, 33-ohm, and 15-ohm resistors. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. The number of 56-ohm resistors is m, the number of 33-ohm resistors is n, and the number of 15-ohm resistors is p. d. Test the formula written for Exercise 1c using the following sample data: m=17,n=24,andp=12.(Physics) You’ve been asked to write a program to calculate the value of distance, in miles, given this relationship: distance=rateelapsedtime a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 2c, using the following sample data: rate is 55 miles per hour and elapsed time is 2.5 hours. e. How must the formula you determined in Exercise 2c be modified if the elapsed time is given in minutes instead of hours?(Electrical eng.) You’ve been asked to write a program that outputs the following specifications: Voltage amplification: 35 Power output: 2.5 watts Bandwidth: 15 KHz a. For this programming problem, how many lines of output are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items.4E(General math) Consider the following programming problem: In 1627, Manhattan Island was sold to Dutch settlers for $24. If the proceeds of this sale had been deposited in a Dutch bank paying 5% interest, compounded annually, what would the principal balance be at the end of 2002? The following display is required: “Balance as of December 31, 2002 is: xxxxxx”; xxxxxx is the amount calculated by your program. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 5c, using the data given in the problem statement.6E(Statistics) This is the formula for the standard normal deviate, z, used in statistical applications: z=(X)/ X is a single value. refers to an average value. refers to a standard deviation. Using this formula, you need to write a program that calculates and displays the value of the standard normal deviate when X=85.3,=80,and=4. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 7c, using the data given in the problem.8E(Practice) Determine a step-by-step procedure (list the steps) to do the following tasks: a. Fix a flat tire. b. Make a telephone call. c. Log on to a computer. d. Roast a turkey.2E3E4E5E(Numerical) a. Write a set of detailed, step-by-step instructions in English to calculate the fewest number of dollar bills needed to pay a bill of amount TOTAL. For example, if TOTAL is $97, the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (For this exercise, assume that only $100, $50, $20, $10, $5, and $1 bills are available.) b. Repeat Exercise 6a, but assume the bill is to be paid only in $1 bills.(Data processing) a. Write an algorithm to locate the first occurrence of the name JEAN in a list of names arranged in random order. b. Discuss how you could improve your algorithm for Exercise 7a if the list of names were arranged in alphabetical order.(Data processing) Determine and write an algorithm to determine the total occurrences of the letter e in any sentence.(Numerical) Determine and write an algorithm to sort four numbers into ascending (from lowest to highest) order.(Conversion) Determine which of the following equations can’t be valid because they yield incorrect unit measurements: a.F=mab.F=m( v 2 /t)c.d=( at 2 )d.d=vte.F=mvtF=force(N)m=mass( kg)a=acceleration( m/s 2 )v=velocity( m/s)t=time(s)(Conversion) An object’s polar moment of inertia, J, represents its resistance to twisting. For a cylinder, this moment of inertia is given by this formula: J=mr2/2+m( l 2 +3r 2 )/12misthecylindersmass( kg).listhecylinderslength(m).risthecylindersradius(m). Using this formula, determine the units for the cylinder’s polar moment of inertia.3PP4PP5PP6PP7PP8PP(Practice) State whether the following are valid function names and if so, whether they’re mnemonic names that convey some idea of the function’s purpose. If they are invalid names, state why. powerdensity m1234 newamp 1234 abcd total tangent absval computed b34a 34ab volts$ a2B3 while minVal sine $sine cosine speed netdistance sum return stack2E3E(Practice) Determine names for functions that do the following: a. Find the average of a set of numbers. b. Find the area of a rectangle. c. Find the minimum value in a set of numbers. d. Find the density of a steel door. e. Sort a set of numbers from lowest to highest(Program) a. Using cout, write a C++ program that displays your name on one line, your street address on a second line, and your city, state, and zip code on a third line. b. Run the program you have written for Exercise 5a. (Note: You must understand the procedures for entering and running a C++ program on the particular computer installation you’re using.)(Program) a. Write a C++ program to display the following output: The cosecant of an angle is equal to one over the sine of the angle. b. Compile and run the program you have written for Exercise 6a.(Program) a. How many cout statements would you use to display the following output? Degrees Radians 0 0.0000 90 1.5708 180 3.1416 270 4.7124 360 6.2832 b. What’s the minimum number of cout statements that could be used to print the output in Exercise 7a? c. Write a complete C++ program to produce the output shown in Exercise7a. d. Run the program you have written for Exercise 7c.(Program) a. Assuming your compiler isn’t case sensitive, determine which of these program unit names are equivalent: AVERAG averag MODE BESSEL Mode Total besseL TeMp Density TEMP denSITY MEAN total mean mode b. Redo Exercise 8a, assuming a case-sensitive compiler.(Practice) You’re given the task of wiring and installing lights in your attic. Determine a set of subtasks to accomplish this task. (Hint: The first subtask is determining the placement of light fixtures.)(Practice) You’re given the job of preparing a complete meal for five people next weekend. Determine a set of subtasks to accomplish this task. (Hint: One subtask, not necessarily the first, is buying the food.)(Practice) You’re a sophomore in college and are planning to go to graduate school for a master’s degree in electrical engineering after you graduate. List a set of major objectives you must fulfill to meet this goal. (Hint: One subtask is “Determine the correct courses to take.”)(Practice) You’re given the job of planting a vegetable garden. Determine a set of subtasks to accomplish this task. (Hint: One subtask is planning the garden’s layout.)(Practice) You’re responsible for planning and arranging the family camping trip this summer. List a set of subtasks to accomplish this task. (Hint: One subtask is selecting the campsite.)(Data processing) a. A national medical testing laboratory wants a new computer system to analyze its test results. The system must be capable of processing each day’s results as well as retrieving and outputting a printed report of all results meeting certain criteria, such as all results for a particular doctor or for hospitals in a certain state. Determine three or four major program units into which this system could be separated. (Hint: One possible program unit is “Prepare Daily Results” to create each day’s reports.) b. Suppose someone enters incorrect data for a test result, and the error is discovered after the system has entered and stored the data. What program unit is needed to correct this problem? Discuss why such a program unit might or might not be required by most systems. c. A program unit has been developed that allows users to change data that has been entered and stored incorrectly. Discuss the need for including an “audit trail” that would allow reconstructing the changes later as well as when they were made and who made them.(Debug) a. Will the following program work? #include using namespace std; int main() {cout << “Hello there world!”; return 0;} b. Even if the program in Exercise 1a works, explain why it’s not a good program.(Modify) Rewrite the following programs to conform to good programming practice and correct syntax: a. #include using namespace std; int main( ){ cout << “The time has come” ; return 0;} b. #include using namespace std; int main ( ){cout << “Newark is a city\n”;cout << “in New Jersey\n”; cout << “It is also a city\n” ; cout << “in Delaware\n” ; return 0;} c. #include using namespace std; int main() {cout << Reading a program\n”;cout << “is much easier\n” ; cout << “if a standard form for main is used\n” ; cout <<“and each statement is written\n”;cout << “on a line by itself\n” ; return 0;} d. #include using namespace std; int main ( ){ cout << “Every C++ program” ; cout <<“\nmust have one and only one” ; cout << “main function” ; cout << “\n The escape sequence of characters”) ; cout << “\nfor a newline can be placed anywhere” ; cout <<“\n in the message passed to cout” ; return 0;}(For thought) a. When used in a message, the backslash character alters the meaning of the character immediately following it. If you want to print the backslash character, you have to tell cout to escape from the way it normally interprets the backslash. What character do you think is used to alter the way a single backslash character is interpreted? b. Using your answer to Exercise 3a, write the escape sequence for printing a backslash.(For thought) a. A token of a computer language is any sequence of characters, with no intervening characters or white space, that taken as a unit has a unique meaning. Using this definition of a token, determine whether escape sequences, function names, and the keywords listed in Table 2.1 are tokens of the C++ language. b. Discuss whether adding white space to a message alters the message and whether messages can be considered tokens of C++. c. Using the definition of a token in Exercise 4a, determine whether the following statement is true: “Except for tokens of the language, C++ ignores all white space.”(Practice) Determine data types appropriate for the following data: a. The average of four grades b. The number of days in a month c. The length of the Golden Gate Bridge d. The numbers in a state lottery e. The distance from Brooklyn, NY to Newark, NJ f. The single-character prefix that specifies a component type(Practice) Compile and run Program 2.5.3E(Practice) Show how the name KINGSLEY is stored in a computer that uses the ASCII code by drawing a diagram similar to Figure 2.7, shown previously.5E6E7E(For thought) Although you have concentrated on operations involving integer and floatingpoint numbers, C++ allows adding and subtracting characters and integers. (These operations are possible with characters because they’re integer data types and are stored by using integer codes.) Therefore, characters and integers can be mixed in arithmetic expressions. For example, if your computer uses the ASCII code, the expression 'a'+1equals'b'and'z'1equals'y'.Similarly,'A'+1is'B'and'Z'-1is'Y'. With this information as background, determine the character results of the following expressions. (Assume all characters are stored by using ASCII codes.) a.m5b.m+5c.G+6d.G6e.baf.ga+1g.GA+1(Practice) Although the total number of bytes varies from computer to computer, memory sizes of millions and billions of bytes are common. In computer language, the letter M representsthe number 1,048,576, which is 2 raised to the 20th power, and G represents 1,073,741,824, which is 2 raised to the 30th power. Therefore, a memory size of 4 MB is really 4 times 1,048,576 (4,194,304 bytes), and a memory size of 2 GB is really 2 times 1,073,741,824 (2,147,483,648 bytes). Using this information, calculate the actual number of bytes in the following: a. A memory containing 512 MB b. A memory consisting of 512 MB words, where each word consists of 2 bytes c. A memory consisting of 512 MB words, where each word consists of 4 bytes d. A thumb drive that specifies 2 GB e. A disk that specifies 4 GB f. A disk that specifies 8 GB(Practice) For the following correct algebraic expressions and corresponding incorrect C++ expressions, find the errors and write corrected C++ expressions: Algebra C++ Expression a.(2)(3)+(4)(5)(2)(3)+(4)(5) b. 6+1826+18/2 c. 4.512.23.1S4.5/12.23.1 d. 4.6(3.0+14.9)4.6(3.0+14.9) e. (12.1+18.9)(15.33.8)(12.1+18.9)(15.33.8)(Practice) Determine the values of the following integer expressions: a.3+46f.202/( 6+3)b.34/6+6g.( 202)/6+3c.23/128/4h.( 202)/( 6+3)d.10( 1+73)i.5020e.202/6+3j.( 10+3)4(Practice) Determine the value of the following floating-point expressions: a.3.0+4.06.0b.3.04.0/6.0+6.0c.2.03.0/12.08.0/4.0 d.10.0( 1.0+7.03.0)e.20.02.0/6.0+3.0f.20.02.0/( 6.0+3.0)g.( 20.02.0)/6.0+3.0h.( 20.02.0)/( 6.0+3.0)(Practice) Evaluate the following mixed-mode expressions and list the data type of the result. In evaluating the expressions, be aware of the data types of all intermediate calculations. a.10.0+15/2+4.3b.10.0+15.0/2+4.3c.3.04/6+6d.34.0/6+6e.20.02/6+3f.10+173+4g.10+17/3.0+4h.3.046+6i.10+173+45E6E7E8E9E(Program) Write a C++ program that displays the results of the expressions 3.05.0,7.18.32.2,and3.2/(6.15) . Calculate the value of these expressions manually to verify that the displayed values are correct.11E(Practice) State whether the following variable names are valid. If they are invalid, state the reason. prod_a c1234 abcd _c3 12345 newamp watts $total new$al a1b2c3d4 9ab6 sum.of average volts1 finvolt2E(Practice) a. Write a declaration statement to declare that the variable count will be used to store an integer. b. Write a declaration statement to declare that the variable volt will be used to store a floating-point number. c. Write a declaration statement to declare that the variable power will be used to store a double-precision number. d. Write a declaration statement to declare that the variable keychar will be used to store a character.4E5E6E7E8E(Practice) a. Using Figure 2.14 and assuming the variable name rate is assigned to the byte at memory address 159, determine the addresses corresponding to each variable declared in the following statements. Also, fill in the correct number of bytes with the initialization data included in the declaration statements. (Use letters for the characters, not the computer codes that would actually be stored.) floatrate; charch1=M,ch2=E,ch3=L,ch4=T; doubletaxes; intnum,count=0; b. Repeat Exercise 9a, but substitute the actual byte patterns that a computer using the ASCII code would use to store characters in the variables ch1, ch2, ch3, and ch4. (Hint: Use Appendix B.)10E11E(Modify) a. Modify Program 2.11 to calculate the speed of a car whose received radar frequency is 2.00000035 10 10 se c 1 . b. Compile and run the program written for Exercise 1a.(Modify) a. Modify Program 2.11 to determine the frequency returned by a car traveling at 55 mph. Your program should produce the following display (replacing the underlines with the values your program calculates): The returned frequency corresponding to 55 mph is _____ b. Compile and run the program written for Exercise 2a. Make sure to do a hand calculation so that you can verify the results your program produces. c. After verifying the results of the program written in Exercise 2a, modify the program to calculate the returned frequency of a car traveling at 75 mph.3E4E(Conversion) a. Design, write, compile, and run a C++ program to convert temperature in degrees Fahrenheit to degrees Celsius. This is the equation for this conversion: Celsius=5.0/9.0(Fahrenheit32.0) Have your program convert and display the Celsius temperature corresponding to 98.6 degrees Fahrenheit. Your program should produce the following display (replacing the underlines with the correct values): For a Fahrenheit temperature of ___ degrees, the equivalent Celsius temperature is ___ degrees. b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to convert 86.5 degrees Fahrenheit to its equivalent Celsius value.(Hydraulics) a. Write, compile, and run a C++ program to calculate the horizontal force exerted on the T-connector pipe shown in Figure 2.16 when the mass flow rate is 1.5 kg/s, and the fluid’s velocity entering the T-connector is 3 m/s. The formula for determining this force is as follows: Fh=MfvFhisthehorizontalforce(N).Mfisthemassflowrate( kg/s).visthevelocity( m/s)ofthefluidenteringthepipe. Your program should produce the following display (replacing the xxxx with the actual force value your program calculates): The horizontal force, in Newtons, is xxxx b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to calculate the force exerted when the mass flow rate is 2.3 kg/s, and the velocity of the fluid entering the pipe is 4.25 m/s.(Thermodynamics) a. Design, write, compile, and run a program that determines the work,W, performed by a piston engine providing a force of 1000 N over a distance of 15 centimeters. The following formula is used to determine the work performed: W=Fd F is the force provided by the piston in Newtons. d is the distance the piston moves in meters. b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the work performed by six pistons, each providing a force of 1500 N over a distance of 20 centimeters.8E(General math) a. Design, write, compile, and run a C++ program that calculates and displays the area of a triangle, such as the one in Figure 2.18, with a base of 1 in and a height of 1.5 in. The area is given by this formula: Area=12(base)(height) b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the area of a two-dimensional triangle with a base of 3.5 in and a height of 1.45 in.(General math) a. Design, write, compile, and run a C++ program to calculate the volume of a sphere with a radius, r, of 2 in. The volume is given by this formula: Volume=4r33 b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the volume of a cube with a radius of 1.67 in.(Physics) a. Design, write, compile, and run a C++ program to calculate the elapsed time it takes to make a 183.67-mile trip. This is the formula for computing elapsed time: elapsedtime=totaldistance/averagespeed The average speed during the trip is 58 mph. b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the elapsed time it takes to make a 372-mile trip at an average speed of 67 mph.4PP(Hydraulics) a. Design, write, compile, and run a C++ program that calculates and displays the velocity of water flowing out of the tube shown in Figure 2.19. The velocity of water flowing into the tube is 1 ft/sec, the input tube radius is 0.75 in, and the output tube radius is 0.5 in. The output velocity is given by this formula: vout=vin( r in r out )2 v outistheoutputvelocity.v inistheinputvelocity.routistheradiusoftheoutputtube.r inistheradiusoftheinputtube. b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the output velocity for a tube having an input radius of 1 in and an output radius of .75 in, when water is flowing into the tube at a rate of 1.5 ft/sec.6PP(Physics) a. The weight of an object on Earth is a measurement of the downward force onth e object caused by Earth’s gravity. The formula for this force is determined by using Newton’s Second Law: F=MAeFistheobjectsweight.Mistheobjectsmass.AeistheaccelerationcausedbyEarthsgravity( 32.2ft/se c 2 =9.82m/ s 2 ). Given this information, design, write, compile, and run a C++ program to calculate the weight in lbf of a person having a mass of 4 lbm. Verify the result produced by your program with a hand calculation. b. After verifying that your program is working correctly, use it to determine the weight, on Earth, of a person having a mass of 3.2 lbm.(Modify) a. Modify the program you wrote for Exercise 7 to provide the mass of a person as an output, given his or her weight as an input to the program. Use your program to determine the mass of a person who weighs 140 lbf on Earth. b. Modify the program written for Exercise 7a to also output the person’s weight on Mars and the moon. The pull of gravity on Mars is 12.54ft/sec2=3.728m/s2,andonthemoonis5.33ft/sec2=1.625m/s2.(Civil eng.) The maximum load that can be placed at the end of a symmetrical wooden beam, such as the rectangular beam shown in Figure 2.20, can be calculated as the following: L=S1dc L is the maximum weight in lbs of the load placed on the beam. S is the stress in lbs/in2. I is the beam’s rectangular moment of inertia in units of in4. d is the distance in inches that the load is placed from the fixed end of the beam (the “moment arm”). c is one-half the height in inches of the symmetrical beam. For a 2” × 4” wooden beam, the rectangular moment of inertia is given by this formula: I=baseheight3=12=24312=10.674 c=(4in)=2in a. Using this information, design, write, compile, and run a C++ program that computes the maximum load in lbs that can be placed at the end of an 8-foot 24 wooden beam so that the stress on the fixed end is 3000lb/in2. b. Use the program developed in Exercise 9a to determine the maximum load in lbs that can be placed at the end of a 3” × 6” wooden beam so that the stress on the fixed end is 3000lb/in2.(Civil eng.) Modify the program written for Exercise 9 to determine the maximum load that can be placed at the end of an 8-foot I-beam, shown in Figure 2.21, so that the stress on the fixed end is 20,000lbs/in2. Use the fact that this beam’s rectangular moment of inertia is 21.4 in4 and the value of c is 3 in.(Mechanical eng.) The minimum radius required for a cylindrical rod, such as one supporting a bicycle pedal (see Figure 2.22), to provide enough support for the pressure exerted by the rider’s foot yet not exceed the stress placed on the crank arm’s sprocket attachment, is given by this formula: r3=dPS r is the radius of the cylindrical rod in inches. d is the length of the crank arm in inches. P is the weight placed on the pedal in lbs. S is the stress in lbs/in2. Using this information, design, write, compile, and run a C++ program that computes the value of r for a crank arm that’s 7 inches long, accommodates a maximum weight of 300 lbs, and is able to sustain a stress of 10,000 lbs/in2.(General math) Write an assignment statement to calculate the circumference of a circle having a radius of 3.3 inches. The formula for determining the circumference, c, of a circle is c=2r, where r is the radius and p equals 3.1416.(General math) Write an assignment statement to calculate the area of a circle. The formula for determining the area, a, of a circle is a=r2, where r is the radius and =3.1416.(Conversion) Write an assignment statement to convert temperature in degrees Fahrenheit to degrees Celsius. The formula for this conversion is Celsius=5/9(Fahrenheit32).4E(Physics) Write an assignment statement to calculate the elapsed time, in minutes, it takes to make a trip. The formula for computing elapsed time is elapsed time = total distance / average speed. Assume the distance is in miles and the average speed is in miles per hour (mph).(Numerical) Write an assignment statement to calculate the nth term in an arithmetic sequence. This is the formula for calculating the value, v, of the nth term: v=a+(n1)d a is the first number in the sequence. d is the difference between any two numbers in the sequence.(Civil eng.) Write an assignment statement to calculate the linear expansion in a steel beam as a function of temperature increase. The formula for linear expansion, l, is as follows: l=l0(1+(TfT0)) l0isthelengthofthebeamattemperatureT0.isthecoefficientoflinearexpansion.Tfisthefinaltemperatureofthebeam.(Physics) Coulomb’s Law states that the force, F, acting between two electrically charged spheres is given by this formula: F=kq1q2r2 q1isthechargeonthefirstsphere.q2isthechargeonthesecondsphere.risthedistancebetweenthecentersofthetwospheres.kisaproportionalityconstant. Write an assignment statement to calculate the force, F.(Civil eng.) Write an assignment statement to determine the maximum bending moment, M, of a beam, given this formula: M=XW(LX)L X is the distance from the end of the beam that a weight, W, is placed. L is the length of the beam.(Desk check) Determine the output of the following program: includeiostreamusingnamespacestd;intmain()//aprogramillustratingintegertruncationintnum1,num2;num1=9/2;num2=17/4;coutthefirstintegerdisplayedisnum1endl;coutthesecondintegerdisplayedisnum2endl;return0;(Debug) Determine and correct the errors in the following programs. a.includeiostreamusingnamespacestd;intmain()width=15area=lengthwidth;coutTheareaisareab.includeiostreamusingnamespacestd;intmain()intlength,width,area;area=lengthwidth;length=20;width=15;coutTheareaisarea;return0;c.includeiostreamintmain()intlength=20;width=15,area;lengthwidth=area;coutTheareais,area;return0;12E13E(General math) The area of an ellipse (see Figure 3.5) is given by this formula: Area=ab Using this formula, write a C++ program to calculate the area of an ellipse having a minor axis, a, of 2.5 inches and a major axis, b, of 6.4 inches.15E1E2E(Practice) Write a C++ program that displays the results of the expressions 3.05.0,7.18.32.2,and3.2/(6.15). Calculate the value of these expressions manually to verify that the displayed values are correct.4E5E6E7E8E(Electrical eng.) The combined resistance of three resistors connected in parallel, as shown in Figure 3.7, is given by this formula: combinedresistance=1(1 R 1 )(1 R 2 )(1 R 3 ) Using this formula, write a C++ program to calculate and display the combined resistance when the three resistors R1 = 1000, R2 = 1000, and R3 = 1000 are connected in parallel. The output should produce this display: The combined resistance is xxxx.xx ohms The xxxx.xx denotes placing the calculated value in a field width of seven columns, with two positions to the right of the decimal point.10E11E(Civil eng.) Write a C++ program to calculate and display the maximum bending moment, M, of a beam that’s supported on both ends (see Figure 3.8). The formula is M=XW(LX)/L, where X is the distance from the end of the beam that a weight, W, is placed, and L is the beam’s length. You program should produce this display: The maximum bending moment is xxxx.xxxx The xxxx.xxxx denotes placing the calculated value in a field wide enough for four places to the right and left of the decimal point. For your program, assign the values1.2,1.3,and11.2toX,W,andL.1E2E(Practice) Write C++ statements for the following: a.b=sinxcosxb.b=sin2xcos2xc.area=( cbsina)/2d.c= a 2 + b 2 e.p= | mn|f.sum= a( r n 1) r14E(General math) Write, compile, and run a C++ program to calculate the distance between two points with the coordinates (7, 12) and (3, 9). Use the fact that the distance between two points with the coordinates (x1, y1) and (x2, y2) is given by this formula: distance=(x2+y2) After verifying that your program works correctly by calculating the distance between the two points manually, use your program to determine the distance between the points (-12, -15) and (22, 5).(General math) If a 20-foot ladder is placed on the side of a building at an 85-degree angle, as shown in Figure 3.11, the height at which the ladder touches the building can be calculated as height=20sin85. Calculate this height by hand, and then write, compile, and run a C++ program that determines and displays the value of the height. After verifying that your program works correctly, use it to determine the height of a 25-foot ladder placed at an angle of 85 degrees.(Physics) The maximum height reached by a ball thrown with an initial velocity, v,inmeters/sec,atanangleof is given by this formula: height=(.5v2sin2)/9.8 Using this formula, write, compile, and run a C++ program that determines and displays the maximum height reached when the ball is thrown at 5 mph at an angle of 60 degrees. (Hint: Make sure to convert the initial velocity into the correct units. There are 1609 meters in a mile.) Calculate the maximum height manually, and verify the result your program produces. After verifying that your program works correctly, use it to determine the height reached by a ball thrown at 7 mph at an angle of 45 degrees.(Transportation) Road construction requires estimating the expected loads on a road’s pavement over its design life. A common approach for determining this information is to use ESAL values; one ESAL is the load a single 18,000-lb (80,000 N) single-axle truck applies to the road’s surface. The ESAL value for any single-axle vehicle can be approximated by this formula: ESAL=[W18,000]4 ESAL is the equivalent single-axle load. W is the vehicle’s weight (lbs). Using this formula, write, compile, and run a C++ program that determines ESAL values and use it to complete the following chart. The ESAL values should be output in a field width of 10, with six digits after the decimal point.9E10E11E12E1E(Practice) a. Write a C++ program that first displays the following prompt: Enter the temperature in degrees Celsius: Have your program accept a value entered from the keyboard and convert the temperature entered to degrees Fahrenheit, using this formula: Fahrenheit=(9.0/5.0)Celsius+32.0 Your program should then display the temperature in degrees Fahrenheit with an appropriate message. b. Compile and run the program written for Exercise 2a. To verify your program, use the following test data and calculate the Fahrenheit equivalents by hand, and then use your program to see whether you get the same results: Testdataset1:0degreesCelsiusTestdataset2:50degreesCelsiusTestdataset3:100degreesCelsius When you’re sure your program is working correctly, use it to complete the following chart3E4E5E6E(General math) a. Write, compile, and run a C++ program to compute and display the value of the second-order polynomial ax2+bx+c for any user-entered values of the coefficients a, b, c, and the variable x. Have your program display a message to inform users what the program does, and then display suitable prompts to alert users to enter the data. (Hint: Use a prompt such as Enter the coefficient of the x-squared term:.) b. Check the result of your program written for Exercise 7a by using the following test data: Testdataset1:a=0,b=0,c=22,x=56Testdataset2:a=0,b=22,c=0,x=2Testdataset3:a=22,b=0,c=0,x=2Testdataset4:a=2,b=4,c=5,x=2 After finishing your verification, use your program to complete the following chart8E9E(Electrical eng.) For the series circuit shown in Figure 3.16, the voltage drop, V2 , across resistor R2 and the power, P2 , delivered to this resistor are given by the formulas V2=IR2andP2=IV2,whereI=E/(R1+R2). Using these formulas, write, compile, and run a C++ program that prompts users for values of E, R1, and R2 ; calculates the voltage drop and power delivered to R2 ; and displays the results. Check your program by using the test data E=10volts,R1=100ohms,andR2=200ohms. After finishing your verification, use your program to complete the following chart:11E12E13E1E2E3E4E5E1E(General math) The value of p can be approximated by this series: 4(113+1517+....) Using this formula, write a program that calculates and displays the value of , using 2, 3, and 4 terms of the series.3E(General math) The volume of oil stored in an underground 200-foot deep cylindrical tank is determined by measuring the distance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank, the volume of oil in the tank can be determined by using this formula: volume=radius2(200distance) Using this information, write, compile, and run a C++ program that accepts the radius and distance measurements, calculates the volume of oil in the tank, and displays the two input values and the calculated volume. Verify the results of your program by doing a hand calculation using the following test data: radius=10feetanddistance=12feet.5E(General math) The perimeter, approximate surface area, and approximate volume of an in-ground pool are given by the following formulas: perimeter=2( length+width)volume=lengthwidthaveragedepthundergroundsurfacearea=2( length+width)averagedepth+lengthwidth Using these formulas as a basis, write a C++ program that accepts the length, width, and average depth measurements, and then calculates the pool’s perimeter, volume, and underground surface area. In writing your program, make these two calculations immediately after entering the input data:lengthwidthandlength+width. The results of these two calculations should be used as needed in the assignment statements for determining the perimeter, volume, and underground surface area without recalculating them for each equation. Verify your program’s results by doing a hand calculation, using the following test data :length=25feet,width=15feet,andaveragedepth=5.5feet. After verifying that your program is working, use it to complete the following chart:7E8E9E(General math) a. Write a C++ program to calculate and display the value of the slope of the line connecting two points with the coordinates (3,7) and (8,12). Use the fact that the slope between two points with the coordinates (x1,y1)and(x2,y2)is(y2y1)/(x2x1). b. How do you know the result your program produced is correct? c. After verifying the output your program produces, modify it to determine the slope of the line connecting the points (2,10) and (12,6). d. What do you think will happen if you use the points (2,3) and (2,4), which results in a division by zero? How do you think this situation can be handled? e. If your program doesn’t already do so, change its output to this: The value of the slope is xxx.xx The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.General math) a. Write a C++ program to calculate and display the midpoint coordinates of the line segment connecting the two endpoints given in Exercise 1a. Use the fact that the coordinates of the midpoint between two points with the coordinates x1,y1)and(x2,y2)are((x1+x2)/2,(y1+y2)/2). Your program should produce the following display (replacing the underscores with values your program calculates): ThexmidpointcoordinateisTheymidpointcoordinateis b. How do you know the midpoint values your program calculates are correct? c. After verifying the output your program produces, modify it to determine the midpoint coordinates of the line connecting the points (2,10) and (12,6). d. If your program doesn’t already do so, change its output to this: The x coordinate of the midpoint is xxx.xx The y coordinate of the midpoint is xxx.xx The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.(General math) Modify the program written for Exercise 2 so that it accepts the x- and y-coordinates of two points. Have your program determine and display the midpoints of the two points (using the formula given in Exercise 2). Verify your program by using the following test data: Testdataset1:Point1=( 0,0)andPoint2=( 16,0)Testdataset2:Point1=( 0,0)andPoint2=( 0,16)Testdataset3:Point1=( 0,0)andPoint2=( 16,0)Testdataset4:Point1=( 0,0)andPoint2=( 0,16)Testdataset5:Point1=( 5,5)andPoint2=( 5,5) When you have finished your verification, use your program to complete the following chart:(Biology) The number of bacteria, B, in a culture that’s subject to refrigeration can be approximated by this formula: B=300000e0.032t e is Euler’s number 2.71828 (rounded to five decimal places). t is the time in hours the culture has been refrigerated. Using this formula, write, compile, and run a C++ program that prompts the user for a value of time, calculates the number of bacteria in the culture, and displays the result. For testing purposes, check your program by using a test input of 10 hours. After verifying your program, use it to determine the number of bacteria in the culture after 12, 18, 24, 36, 48, and 72 hours.5PP(Heat transfer) The formula developed in Exercise 5 can be used to determine the cooling time, t, caused only by radiation, of each planet in the solar system. For convenience, this formula is repeated here (see Exercise 5 for a definition of each symbol): t=Nk2eAT3fin A=surfaceareaofasphere=4r2 N=numberofatoms=volumeofthespherevolumeofanatom Volume of a sphere sphere=43radius3 The volume of a single atom is approximately 11029m3 . Using this information and the current temperatures and radii listed in the following chart, determine the time it took each planet to cool to its current temperature, caused only by radiation.7PP(Electrical eng.) a. The voltage gain of an amplifier is given by this formula: voltagegain=[275 23 2 +0.5 f 2 ]n f is the frequency in Hz. n is the number of stages in the amplifier. Using this formula, write, compile, and run a C++ program to determine the value of the voltage gain for a four-stage amplifier operating at a frequency of 120 Hz. Your program should produce the following display: At a frequency of xxxxx hertz, the voltage gain is yyyyy Your program should replace xxxxx with the frequency and yyyyy with the voltage gain. b. Manually check the value your program produces. After verifying that your program is working correctly, modify it to determine the voltage gain of a 12-stage amplifier operating at a frequency of 9500 Hz.(Electrical eng.) a. Write, compile, and run a C++ program that calculates and displays the value of the current flowing through an RC circuit (see Figure 3.19). The circuit consists of a battery connected in a series to a switch, a resistor, and a capacitor. When the switch is closed, the current, i, flowing through the circuit is given by this formula: i=(EIR)et/RC Eisthevoltageofthebatteryinvolts.Risthevalueoftheresistorinohms.Cisthevalueofthecapacitorinfarads.tisthetimeinsecondsaftertheswitchisclosed.eisEulersnumber,whichis2.71828( roundedtofivedecimalplaces). Using this formula, write, compile, and run a C++ program to determine the voltage across the capacitor shown in Figure 3.19 when t is 0.31 seconds. (Note: The value of RC is referred to as the system’s time constant.) The program should prompt the user to enter appropriate values and use input statements to accept the data. In constructing the prompts, use statements such as “Enter the voltage of the battery.” Verify your program’s operation by calculating by hand the current for the following test data: Testdataset1:Voltage=20volts,R=10ohms,RC=0.044,t=0.023secondsTestdataset2:Voltage=35volts,R=10ohms,RC=0.16,t=0.067seconds b. Check the value computed by your program by hand. After verifying that your program is working correctly, use it to complete the following chart:(Electrical eng.) The amplification of electronic circuits is measured in units of decibels, which is calculated as the following: 10LOG(Po/Pi) Po is the power of the output signal, and Pi is the power of the input signal. Using this formula, write, compile, and run a C++ program to calculate and display the decibel amplification, in which the output power is 50 times the input power. Verify your program’s result by doing a hand calculation. After verifying that your program is working correctly, use it to determine the amplification of a circuit, where output power is 4.639 watts and input power is 1 watt.(Acoustics) The loudness of a sound is measured in units of decibels and is calculated as shown: 10LOG(SL/RL) SL is the intensity of the sound being measured. RL is a reference sound-intensity level. Using this formula, write a C++ program that calculates and displays the decibel loudness of a busy street having a sound intensity of 10,000,000 RL. Verify your program’s result by doing a hand calculation. After verifying that your program is working correctly, use it to determine the sound level in decibels of the following sounds: a.Awhisperatsoundintensity200RLb.Arockbandplayingatsoundintensity1,000,000,000,000RLc.Anairplanetakingoffatsoundintensity100,000,000,000,000RL(General math) a. A balance has the following weights: 100 lb, 50 lb, 10 lb, 5 lb, and 1 lb. The number of 100 lb and 50 lb weights required to weigh an object weighing WEIGHT pounds can be calculated by using the following C++ statements: //Determinethenumberof100lbweightsw100=int( WEIGHT/100)//Determinethenumberof50lbweightsw50=int( ( WEIGHTw100100 )/50) Using these statements as a starting point, write a C++ program that calculates the number of each type of weight needed to weigh a 789 lb object. b. Without compiling or running your program, manually check the effect of each statement in the program and determine what’s stored in each variable as each statement is encountered. c. After verifying that your algorithm works correctly, compile and run your program. Verify that the results your program produces are correct. After verifying that your program is working correctly, use it to determine the weights required to weigh a 626 lb object.(Practice) Determine the value of the following expressions, assuming a=5,b=2,c=4,d=6,ande=3: a.abb.a!=bc.db==cbd.ac!=dbe.db==cef.!( ab)g.!( abc)h.!( cba)i.bca2E3E4E1E2E3E4E5E6E7E8E9E1E2E3E4E5E6E7E8E9E1E(Practice) Rewrite the following if-else chain by using a switch statement: if( factor==1)pressure=25.0;elseif( factor==2)pressure=36.0;elseif( factor==3)pressure=45.0;elseif( factor==4)|| ( factor==5 )||( factor==6)pressure=49.0;3E4E5E6E1E2E(Data processing) a. Write a program to display the following two prompts: Enter a month (use a 1 for Jan, etc.): Enter a day of the month: Have your program accept and store a number in the variable month in response to the first prompt and accept and store a number in the variable day in response to the second prompt. If the month entered is not between 1 and 12, print a message informing the user that an invalid month has been entered. If the day entered is not between 1 and 31, print a message informing the user that an invalid day has been entered. b. What will your program do if the user enters a number with a decimal point for the month? How can you make sure your if statements check for an integer number? c. In a non-leap year, February has 28 days; the months January, March, May, July, August, October, and December have 31 days; and all other months have 30 days. Using this information, modify the program written in Exercise 3a to display a message when an invalid day is entered for a user-entered month. For this program, ignore leap years.4E(Data processing) Years that are evenly divisible by 400 or are evenly divisible by 4 but not by 100 are leap years. For example, because 1600 is evenly divisible by 400, 1600 was a leap year. Similarly, because 1988 is evenly divisible by 4 but not by 100, it was also a leap year. Using this information, write a C++ program that accepts the year as user input, determines whether the year is a leap year, and displays a message telling the user whether the entered year is or is not a leap year.6E7E8E(Data processing) Write C++ code sections to make the following decisions: a. Ask for two integer temperatures. If their values are equal, display the temperature; otherwise, do nothing. b. Ask for character values letter1 and letter2, representing uppercase letters of the alphabet, and display them in alphabetical order. c. Ask for three integer values, num1, num2, and num3, and display them in decreasing order.2PP3PP(Data processing) a. Write a C++ program to compute and display a person’s weekly salary as determined by the following conditions: If the hours worked are less than or equal to 40, the person receives $12.00 per hour; otherwise, the person receives $480.00 plus $17.00 for each hour worked over 40 hours. The program should request the hours worked as input and display the salary as output. b. How many runs should you make for the program written in Exercise 4a to verify that it’s operating correctly? What data should you input in each program run?5PP6PP7PP8PP9PP10PP11PP12PP13PP14PP(For review) List the three repetition statements provided in C++.2E3E4E(For review) a. What’s the difference between a pretest and posttest loop? b. If the condition being tested in a pretest loop is false, how many times are statements in the loop executed? c. If the condition being tested in a posttest loop is false, how many times are statements in the loop executed?6E(Practice) Rewrite Program 5.1 to print the numbers 2 to 10 in increments of two. The output of your program should be the following: 2 4 6 8 10(Practice) Rewrite Program 5.4 to produce a table starting at a Celsius value of -10 and ending with a Celsius value of 60, in increments of 10 degrees.3E(Conversion) Write a C++ program that converts gallons to liters. The program should display gallons from 10 to 20 in 1-gallon increments and the corresponding liter equivalents. Use the relationship that 1gallon=3.785liters.5E(Practice) An automobile travels at an average speed of 55 mph for 4 hours. Write a C++ program that displays the distance, in miles, the car has traveled after 1, 2, and so on hours until the end of the trip.7E(Numerical analysis) a. The following is an approximate conversion formula for converting Fahrenheit to Celsius temperatures: Celsius=(Fahrenheit30)/2 Using this formula, and starting with a Fahrenheit temperature of 0 degrees, write a C++ program that determines when the approximate equivalent Celsius temperature differs from the exact equivalent value by more than 4 degrees. (Hint: Use a while loop that terminates when the difference between approximate and exact Celsius equivalents exceeds 4 degrees.) b. Using the approximate Celsius conversion formula given in Exercise 8a, write a C++ program that produces a table of Fahrenheit temperatures, exact Celsius equivalent temperatures, approximate Celsius equivalent temperatures, and the difference between the exact and approximate equivalent Celsius values. The table should begin at 0 degrees Fahrenheit, use 2-degree Fahrenheit increments, and terminate when the difference between exact and approximate values is more than 4 degrees.9E10E1E2E3E4E5E(Conversion) a. Write a C++ program to convert meters to feet. The program should request the starting meter value, the number of conversions to be made, and the increment between metric values. The display should have appropriate headings and list the meters and the corresponding feet value. If the number of iterations is greater than 10, have your program substitute a default increment of 10. Use the relationship that 1 meter = 3.281 feet. b. Run the program written in Exercise 6a on a computer. Verify that your program begins at the correct starting meter value and contains the exact number of conversions specified in your input data. c. Modify the program written in Exercise 6a to request the starting meter value, the ending meter value, and the increment. Instead of the condition checking for a fixed count, the condition checks for the ending meter value. If the number of iterations is greater than 20, have your program substitute a default increment of (ending value - starting value) / 19.7E8E(Misc. application) a. The data in the following chart was collected on a recent automobile trip: Write a C++ program that accepts a mileage and gallons value and calculates the miles pergallon (mpg) for that segment of the trip. The mpg is obtained as the difference in mileage between fill-ups divided by the number of gallons of gasoline used in the fill-up. b. Modify the program written for Exercise 9a to also compute and display the cumulative mpg after each fill-up. The cumulative mpg is calculated as the difference between the mileage at each fill-up and the mileage at the start of the trip divided by the sum of gallons used to that point in the trip.(Practice) Write a for statement for each of the following cases: a. Use a counter named i that has an initial value of 1, a final value of 20, and an increment of 1. b. Use a counter named icount that has an initial value of 1, a final value of 20, and an increment of 2. c. Use a counter named j that has an initial value of 1, a final value of 100, and an increment of 5. d. Use a counter named icount that has an initial value of 20, a final value of 1, and an increment of -1. e. Use a counter named icount that has an initial value of 20, a final value of 1, and an increment of -2. f. Use a counter named count that has an initial value of 1.0, a final value of 16.2, and an increment of 0.2. g. Use a counter named xcnt that has an initial value of 20.0, a final value of 10.0, and an increment of -0.5.2E(Desk check) Determine the value in total after each of the following loops is executed: a.total=0;for( i=1;i=10;i=i+1)total=total+1;b.total=1;for( count=1;count=10;count=count+1)total=total2;c.total=0;for( i=10;i=15;i=i+1)total=total+i;d.total=50;for( i=1;i=10;i=i+1)total=totali;e.total=1;for( icnt=1;icnt=8;++icnt)total=totalicnt;f.total=1.0;for( j=1;j=5;++j)total=total/2.0;4E5E6E(Conversion) Write a C++ program to convert kilometers/hr to miles/hr. The program should produce a table of 10 conversions, starting at 60 km/hr and incremented by 5 km/hr. The display should have appropriate headings and list each km/hr and its equivalent miles/hr value. Use the relationship that 1 kilometer=0.6241miles.8E9E10E11E12E1E(cin within a loop) Write and run a C++ program that accepts 10 values of gallons, one at a time, and converts each value entered to its liter equivalent before the next value is requested. Use a for loop in your program. Use the fact that 1gallon=3.785liters.3E4E5E6E7E8E9E10E11E(Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.13E14E(Program) Write a program to simulate the rolling of two dice. If the total of the two dice is 7 or 11, you win; otherwise, you lose. Embellish this program as much as you like with betting, different odds, different combinations for win or lose, stopping play when you have no money left or reach the house limit, displaying the dice, and so forth. (Hint: Calculate the dots showing on each die with theexpressiondots=(int)(6.0randomnumber+1), where random number is between 0 and 1.)(Misc. application) Four experiments are performed, and each experiment has six test results. The results for each experiment are given in the following list. Write a program using a nested loop to compute and display the average of the test results for each experiment. 1stexperimentresults:23.23116.92725.428.62ndexperimentresults:34.845.227.936.833.439.43rdexperimentresults:19.416.810.220.818.913.44thexperimentresults:36.93949.245.142.750.62E(Electrical eng.) a. An electrical manufacturer tests five generators by measuring their output voltages at three different times. Write a C++ program that uses a nested loop to enter each generator’s test results, and then computes and displays the average voltage for each generator. Assume the following generator test results: 1stgenerator:122.5122.7123.02ndgenerator:120.2127.0125.13rdgenerator:121.7124.9126.04thgenerator:122.9123.8126.75thgenerator:121.5124.7122.6 b. Modify the program written for Exercise 3a to calculate and display the average voltage for all the generators. (Hint: Use a second variable to store the total of all the generator’s voltages.)4E(Mathematical functions) Write a program that calculates and displays values for y when y=xz/(xz) Your program should calculate y for values of x ranging between 1 and 5 and values of z ranging between 2 and 6. The x variable should control the outer loop and be incremented in steps of 1, and z should be incremented in steps of 1. Your program should also display the message Function Undefined when the x and z values are equal.6E(Practice) a. Using a do statement, write a program to accept a grade. The program should request a grade continuously as long as an invalid grade is entered. An invalid grade is any grade less than 0 or greater than 100. After a valid grade has been entered, your program should display the value of the grade entered. b. Modify the program written for Exercise 1a so that the user is alerted when an invalid grade has been entered. c. Modify the program written for Exercise 1b so that it allows the user to exit the program by entering the number 999. d. Modify the program written for Exercise 1b so that it automatically terminates after five invalid grades are entered.(Misc. application) a. Write a program that continuously requests a grade to be entered. If the grade is less than 0 or greater than 100, your program should print an appropriate message informing the user that an invalid grade has been entered; else, the grade should be added to a total. When a grade of 999 is entered, the program should exit the repetition loop and compute and display the average of the valid grades entered. b. Run the program written in Exercise 2a and verify the program by using appropriate test data.(Misc. application) a. Write a program to reverse the digits of a positive integer number. For example, if the number 8735 is entered, the number displayed should be 5378. (Hint: Use a do statement and continuously strip off and display the number’s units digit. If the variable numinitially contains the number entered, the units digit is obtained as (num % 10). After a units digit is displayed, dividing the number by 10 sets up the number for the next iteration. Therefore, (873510)is5and(8735/10)is873. The do statement should continue as long as the remaining number is not 0.) b. Run the program written in Exercise 3a and verify the program by using appropriate test data.4E
Page: [1][2][3]