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...
-
A vegetable fiber is traded in a competitive world market, and the world price is $9 per pound. Unlimited quantities are available for import into the United States at this price. The U.S. domestic...
-
Hoboken Industries currently manufactures 30.000 units of part MR24 each month for use in production of several of its products. The facilities now used to produce part MR24 have a fixed monthly cost...
-
Jupiter's is considering an investment in time and administrative expense on an effort that promises one large payoff in the future, followed by additional expenses over a 10-year horizon. The cash...
-
On July 1, 2014, Livingston Corporation, a wholesaler of manufacturing equipment, issued $46,000,000 of 20-year, 10% bonds at a market (effective) interest rate of 11%, receiving cash of $42,309,236....
-
The Oracle Database Upgrade Assistant (DBUA) is a GUI tool but can also run in silent command line mode. As a DBA, in what circumstances would you recommend using silent mode?
-
Given two arrays each of length n, arr1, and arr2, in one operation, any two elements of an array can be swapped. This can occur any number of times. Find the maximum possible sum of i*(arr2[1]-...
-
Refined Touch is a dating service. Rather than using algorithms, the company uses a traditional matchmaker. The company had the following income statement for April 2019: Refined Touch Income...
-
In Cynthia Cooper's memoir and expose' of the accounting fraud that brought down the telecom company WorldCom, the following are players in the drama described in Ms. Cooper's book. Cynthia Cooper -...
-
What is a cost object, direct costs, and indirect costs? How do variable costs and fixed costs differ? Can you explain variable and fixed costs in brief?
-
Freedonia Township is planning to issue a 30 year bond with a face value of $15,000,000 to construct a new sports and recreation center. The Township will make interest payments twice each year. The...
-
Assignment length: 500 words ( Out of 6 question, i have only doubts in this 3 question) Subject : Intercultural Management 1. The national cultural variables 2.Comparing national culture 3.Culture...
-
Hathaway Computer Chip LLC is working on their MOH budget and have provided the following information: Budgeted units to be produced- 4,000, Budgeted variable MOH unit per unit= $0.15, the Budgeted...
-
A housewife makes deposits into a fund at the end of each year for 20 years. She deposits RM1000 annually for the first 10 years and RM(1000+M) for the next 10 years. The fund earns interest at an...
-
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] =
-
Repeat problem 41 with the specimen of size \(100 \times 100 \times 10 \mathrm{~mm}^{3}\) and the dimensions of the cavity \(104 \times 104 \times 9 \mathrm{~mm}^{3}\). Elastic constants of the...
-
Repeat problem 41 with elastic constants of the plastic as \(E=10 \mathrm{GPa}\) and \(v=0.485\). Problem 42: A rectangular plastic specimen of size \(100 \times 100 \times 10 \mathrm{~mm}^{3}\) is...
-
A rectangular plastic specimen of size \(100 \times 100 \times 10 \mathrm{~mm}^{3}\) is placed in a rectangular metal cavity. The dimensions of the cavity are \(101 \times 101 \times 9...
Study smarter with the SolutionInn App