Identify the various assertions in the following code as being always true, never true, or sometimes true
Question:
Identify the various assertions in the following code as being always true, never true, or sometimes true and sometimes false at various points in program execution. The comments indicate the points of interest:
Categorize each assertion at each point with ALWAYS, NEVER, or SOMETIMES.
Transcribed Image Text:
public static int mystery (int n) { Random r = new Random (); int a = r.nextInt (3) + 1; int b = 2; // Point A while (n > b) { // Point B b = b + a; !! if (a > 1) { n--; // Point C a = r.nextInt (b) + 1; } else { a = b + 1; // Point D // Point E return n;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 80% (10 reviews)
Point A Sometimes true Sometimes false Never true Never true Point B Always true Sometimes true Some...View the full answer
Answered By
Joash Mokaya
I am an experienced tutor with more than 7 years of experience. I have helped thousands of students pursue their academic goals. My primary objective as a tutor is to ensure that students have an easy time handling their academic tasks.
0.00
0 Reviews
10+ Question Solved
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted:
Students also viewed these Computer science questions
-
Indicate whether each statement is always true or sometimes false. Justify your answer by giving a logical argument or a counterexample. (a) If ||u + v ||2 = ||u||2 + ||v||2 then u and v are...
-
Indicate whether each statement is always true or sometimes false. Justify your answer by giving a logical argument or a counterexample. (a) If Rn maps Rm into and T(0) = 0, then T is linear. (b) If...
-
Indicate whether each statement is always true or sometimes false. Justify your answer by giving a logical argument or a counterexample. (a) If Ax = b is any consistent linar system of m equations in...
-
The future value S of principal P invested for n years with an interest rate r% compounded annually may be calculated using the formula Rearrange this formula to express P in terms of S, r and n. S =...
-
What is the difference between a refrigerator and a heat pump?
-
Write a program to help a traveler plan the shortest traveling path from one city to another. The program should read a file of data containing a list of cities and a list of roads connecting the...
-
Oil \((S G=0.9)\) flows downward through a vertical pipe contraction as shown in Fig. P5.97. If the mercury manometer reading, \(h\), is \(100 \mathrm{~mm}\), determine the volume flowrate for...
-
Derby, Inc. manufactures golf clubs in three models. For the year, the Eagle line has a net loss of $20,000 from sales $200,000, variable expenses $180,000, and fixed expenses $40,000. If the Eagle...
-
What is personal growth? What is personal growth as a children's pastor What is personal growth as a treasurer at a church What is personal growth as a pastor/ dealing with a supervised pastor...
-
Tubular membranes of silicone rubber can be used for bubble less aeration of water. A cross section of the tube is shown in the figure (right-hand column). Pure oxygen (O 2 ) gas is pressurized to...
-
Identify the various assertions in the following code as being always true, never true, or sometimes true and sometimes false at various points in program execution. The comments indicate the points...
-
Identify the various assertions in the following code as being always true, never true, or sometimes true and sometimes false at various points in program execution. The comments indicate the points...
-
For 2020, Sherri has a short-term loss of $2,500 and a long-term loss of $4,750. a. How much loss can Sherri deduct in 2020? b. How much loss will Sherri carryover to 2021 and what is the character...
-
When will an industry tend to become dominated by platform ecosystems? What will determine which platform ecosystems are more successful in an industry than others?
-
A movie studio executive wants to poll a sample of movie goers to determine how viewers will react to a new movie. Briefly explain how the sample should be designed.
-
Two companies, Boeing and Airbus, have long dominated the market for large commercial jet aircraft. Today Boeing planes account for 50% of the worlds fleet of commercial jet aircraft, and Airbus...
-
Established in 2000 as a joint venture between Verizon Communications and Britains Vodafone, over the last 18 years Verizon Wireless has emerged as the largest and consistently most profitable...
-
The U.S. newspaper business is a declining industry. Newspaper circulation has been steadily falling since 1990, with the drop accelerating in recent years. According to the Newspaper Association of...
-
When applying Kirchhoff 's rules, one of the essential steps is to mark each resistor with plus and minus signs to label how the potential changes from one end of the resistor to the other. The...
-
Prepare a stock card using the following information A company is registered for GST which it pays quarterly, assume GST was last paid on the 30th of June 2019. It uses weighted average cost...
-
Suppose you have a deque D containing the numbers (1,2,3,4,5,6,7,8), in this order. Suppose further that you have an initially empty queue Q. Give a code fragment that uses only D and Q (and no other...
-
What values are returned during the following sequence of deque ADT operations, on an initially empty deque? addFirst(3), addLast(8), addLast(9), addFirst(1), last( ), isEmpty( ), addFirst(2),...
-
Had the queue of the previous problembeen an instance of the ArrayQueue class, from Code Fragment 6.10, with capacity 30 never exceeded, what would be the final value of the instance variable f?
-
Shahid Pakistan Limited (SPL) is engaged in the production of three products: J, K and L. Following is the extract from its latest annual management accounts: Description J Products K Total L Units...
-
John Company produces hats and sells them for $100 each. His cost to produce the hats are: DM 20 per unit DL 30 per unit VMOH 10 per unit FMOH 40,000 Selling expenses are $5 per unit and are all...
-
John Company produces hats and sells them for $100 each. His cost to produce the hats are: DM 20 per unit DL 30 per unit VMOH 10 per unit FMOH 40,000 Selling expenses are $5 per unit and are all...
Study smarter with the SolutionInn App