1: Rewrite the following nested if-else statement as a switch statement that accomplishes exactly the same...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1: Rewrite the following nested if-else statement as a switch statement that accomplishes exactly the same thing. Assume that num is an integer variable that has been initialized, and that there are functions fl, f2, f3, and f4. Do not use any if or if-else statements in the actions in the switch statement, only calls to the four functions. if num < -2 || num > 4 f1 (num) else if num <= 2 if num >= 0 f2 (num) else f3 (num) end else f4 (num) end end Test your switch statement with num: a random integer from -5 to 5, and creating anonymous functions for fl-f4: fl=sin (num), f2=enum cos(num), f3= num?+2*num, f4= arctan(num). QUESTION 2: Write a script that will prompt the user for a quiz grade and error-check until the user enters a valid quiz grade. The script will then echo print the grade. For this case, valid grades are in the range from 0 to 10 in steps of 0.5. Do this by creating a vector of valid grades and then use any or all in the condition in the while loop. 1: Rewrite the following nested if-else statement as a switch statement that accomplishes exactly the same thing. Assume that num is an integer variable that has been initialized, and that there are functions fl, f2, f3, and f4. Do not use any if or if-else statements in the actions in the switch statement, only calls to the four functions. if num < -2 || num > 4 f1 (num) else if num <= 2 if num >= 0 f2 (num) else f3 (num) end else f4 (num) end end Test your switch statement with num: a random integer from -5 to 5, and creating anonymous functions for fl-f4: fl=sin (num), f2=enum cos(num), f3= num?+2*num, f4= arctan(num). QUESTION 2: Write a script that will prompt the user for a quiz grade and error-check until the user enters a valid quiz grade. The script will then echo print the grade. For this case, valid grades are in the range from 0 to 10 in steps of 0.5. Do this by creating a vector of valid grades and then use any or all in the condition in the while loop.
Expert Answer:
Related Book For
Fundamentals of Electric Circuits
ISBN: 9780073301150
3rd edition
Authors: Matthew Sadiku, Charles Alexander
Posted Date:
Students also viewed these programming questions
-
Assume that children is an integer variable containing the number of children in a community, and that families is an integer variable containing the number of families in the same community. Write a...
-
If Number is an integer variable and MyString = "One potato" then the following statement is valid: Number = Length_Of(MyString) True or False
-
Rewrite the following nested if-else statement as a switch statement that accomplishes exactly the same thing. Assume that num is an integer variable that has been initialized, and that there are...
-
Nisha has completed her MBA and has joined a company which was going to raise fund from long term sources such as Debt and Equity. Nisha was asked by her manager to prepare a report on which could be...
-
The Cutting Department of Sonoras Textiles had the following information about production and costs for the month of July: Beginning work in process, 9,200 units that are 100 percent complete as to...
-
\(4-(6+3) \times 5+11\) Perform the indicated calculation.
-
Refer to Exercise 6-3 and assume the periodic inventory system is used. Determine the costs assigned to ending inventory and to cost of goods sold using (a) FIFO, and (b) LIFO. Compute the gross mar...
-
Grizzly Community Hospital in central Wyoming provides health care services to families living within a 200-mile radius. The hospital is extremely well equipped for a relatively small, community...
-
Check here for instructional material to complete this problem. A book is 11 centimeters wide. Convert this width to inches. The width of the book is in. (Round to two decimal places as needed.)
-
1. Create and upload a histogram of the salary data for the city of Bell, where each bar width is about 50,000 US dollars. (Data for the histogram is at the bottom). a.) Is the distribution of the...
-
Write a paper addressing the following issues: Overall, is your current role more of a leadership or a management role? How about your supervisor? Are they a manager or leader? What key differences...
-
Write the equation of a quadratic function in standard form for the parabola that passes through the given points. (-1,5),(4,0),(5,-7),(1,9),(3,5),(0,8).
-
Shrewsbury Technologies, which manufactures high-technology instruments for spacecraft, is considering the sale of a navigational unit to a private company that wishes to launch its own...
-
Cliff Company manufactures file cabinets. The following cost information is available for the month of December: Beginning work in process Direct materials Conversion cost December costs Direct...
-
Maureen Smith is a single individual. She claims a standard deduction of $12,400. Her salary for the year was $213,800. Assume the following tax table is applicable. Single Individuals You Pay This...
-
After liquidating noncash assets and paying creditors, account balances in the Main Co. are Cash $29,000. Partners Johnson, Murry, and Rodriguez have capital credit balances of $11,000, $8,000 and...
-
L The following direct materials variance computations are incomplete Price variance (37-59) 0,000kg Efficiency variance (-10.000 kg)-591 Flexible budget variance 57 -$4,300 U Requirement 1. Fill in...
-
Record the following selected transactions for March in a two-column journal, identifying each entry by letter: (a) Received $10,000 from Shirley Knowles, owner. (b) Purchased equipment for $35,000,...
-
Determine Vx in the circuit of Fig. 10.62 using any method of your choice. , 312 10
-
Repeat prob. 7.65 using PSpice. In Problem 7.65 If the input pulse in Fig. 7.130(a) is applied to the circuit in Fig. 7.130(b), determine the response i(t). e, (V) 542 10 20 211 1 (s)
-
Given that Determine: (a) [z] (b) [y] (c) [h] (d) [T] 0.06S-0.4 0.2 2 [g] =
-
The standard costs for a manufacturing business are \($12\) per unit for direct materials, \($8\) per unit for direct labour, and \($5\) per unit for manufacturing overhead. The sales projection is...
-
What is Munchs expected profit for April? a. $192,500 b. $56,000 c. $66,000 d. $59,000 Munch Enterprises makes a small toy car that is voice activated. Projected sales for the next four months are...
-
Bobby Jones Inc. is planning sales of 55,000 units for the next three months. The company has a beginning inventory of 10,000 units and would like to have an ending inventory of 15,000 at the end of...
Study smarter with the SolutionInn App