Task 1: Using the following source code, answer the questions listed below. 1. public int Funi...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 1: Using the following source code, answer the questions listed below. 1. public int Funi (int x, int k) { 2. int i=0; 3. int y x+k; 4. do ( 5. if (x/2 < 2) { 6. ky x; 7. } 8. else{ 9. xk2; 10. y = y + x; 11. 12. 13. 14. 15. 16. 17. } 18. kxy: i=i+1; while (ix); if (x < 0 && y < 0) { k-y-x; else{ 19. k = y + x; 20. 21. 22.) } return k; (a) Draw a control flow graph to represent the method Fun!, shown above. Label the nodes (starting with A) and the outgoing edges of the decision boxes appropriately. (b) Using the line labels in the code for method Fun!, identify all the def-use pairs for the variables x, k and y. (c) Identify a set of test cases that satisfies the all-defs criterion, for variables x, k and y in method Funl. Use trace tables to show how the def-use pairs are covered. If you cannot achieve 100% coverage for the all-defs criterion please explain why. (d) Identify a set of test cases that satisfies the all-uses criterion, for variables x, k and y in method Funl. Use trace tables to show how the def-use pairs are covered. If you cannot achieve 100% coverage for the all-uses criterion, please explain why. Task 1: Using the following source code, answer the questions listed below. 1. public int Funi (int x, int k) { 2. int i=0; 3. int y x+k; 4. do ( 5. if (x/2 < 2) { 6. ky x; 7. } 8. else{ 9. xk2; 10. y = y + x; 11. 12. 13. 14. 15. 16. 17. } 18. kxy: i=i+1; while (ix); if (x < 0 && y < 0) { k-y-x; else{ 19. k = y + x; 20. 21. 22.) } return k; (a) Draw a control flow graph to represent the method Fun!, shown above. Label the nodes (starting with A) and the outgoing edges of the decision boxes appropriately. (b) Using the line labels in the code for method Fun!, identify all the def-use pairs for the variables x, k and y. (c) Identify a set of test cases that satisfies the all-defs criterion, for variables x, k and y in method Funl. Use trace tables to show how the def-use pairs are covered. If you cannot achieve 100% coverage for the all-defs criterion please explain why. (d) Identify a set of test cases that satisfies the all-uses criterion, for variables x, k and y in method Funl. Use trace tables to show how the def-use pairs are covered. If you cannot achieve 100% coverage for the all-uses criterion, please explain why.
Expert Answer:
Answer rating: 100% (QA)
Answer a Heres the control flow graph CFG for the Fun1 method A ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Read about the increase in Union activity in recent years here: https://www.vox.com/recode/23056599/starbucks-amazon-union-membership-growth 1. What nontraditional industries are seeing increased...
-
Speeding up and slowing down A 1400kg car, starting from rest, accelerates to a speed of 30mph in 10 seconds. a) What is the force on the car (assumed constant) over this period of time? b) Where...
-
If the focal length of a lens is 3 centimeters and the image distance is 5 centimeters from the lens, what is the distance from the object to the lens?
-
Four hospitals located in one county are cooperating to establish a centralized blood-bank facility to serve them all. On an xy coordinate grid of the county, the hospitals are found at the following...
-
Assume that the Poisson distribution has the indicated mean and use Formula 4-10 to find the probability of the value given for the random variable x. = 2, x = 3
-
Why is it more comfortable to hold a cup of hot tea by the handle rather than by wrapping your hands around the cup itself?
-
Why do companies issue credit when their past experience indicates that some customers will not pay? LO22
-
A technology problem has rendered some of the inventory at FFF obsolete. FFF estimates that the risk cost of its inventory is now 10 percent. (a) Calculate the new annual holding cost rate. (b)...
-
TB MC Qu . 8 - 1 1 4 ( Static ) Dilly Farm Supply is located in a small town... Dilly Farm Supply is located in a small town in the rural west. Data regarding the store's operations follow: Sales are...
-
During 2019, COVID Company constructed various assets at a total cost of 8,400,000. The weighted average accumulated expenditures on assets qualifying for capitalization of interest during 2019 were...
-
6. Camel Company uses the FIFO method in its process costing system. The Assembly Department started the month with 5,000 units in its beginning work in process inventory that were 80% complete with...
-
Explain the principles behind NoSQL database design and its suitability for handling unstructured or semi-structured data.
-
Based on a predicted level of production and sales of 37,000 units, a company anticipates total contribution margin of $151,700, fixed costs of $74,000, and income of $77,700. Based on this...
-
You will draft a motion to dismiss the complaint filed against Derek under FRCP 12(b)(2) based on a lack of personal jurisdiction. You will also draft a memorandum of law/points and authorities in...
-
The restaurant at the Hotel Galaxy offers two choices for breakfast: an all-you-can-eat buffet and an a la carte option, where diners can order from the menu. The buffet option has a budgeted meal...
-
Target Profit Woodsman Company sells a product for $110 per unit. The variable cost is $55 per unit, and fixed costs are $385,000. Determine (a) the break-even point in sales units and (b) the...
-
Why is disclosure of depreciation or amortization methods and rates so important?
-
A tiny home uses approximately \(12 \mathrm{~kW}\) of electricity per day. What size solar system would be needed to fuel \(80 \%\) of a home's needs for a month (30 days)?
-
Accrual-and Cash-Basis Expenses} Speedy Delivery Company provides next-day delivery across Eastern Canada. During May, Speedy incurred \(\$ 132,600\) in fuel costs. Speedy paid \(\$ 95,450\) of the...
-
Accrual- and Cash-Basis Revenue Magnani Music sells used CDs for \(\$ 2.00\) each. During the month of April, Magnani sold 8,750 CDs for cash and 15,310 CDs on credit. Magnani's cash collections in...
Study smarter with the SolutionInn App