Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

rcdvital /books 9781133714941 cfi/923 4/40000:128 Assignments Homework Table of

ID: 3576797 • Letter: R

Question

rcdvital /books 9781133714941 cfi/923 4/40000:128 Assignments Homework Table of Contents the flowchart in Figure A-22, what are the values oflan d J at the instant just after the statemen 1 is executed for the fifth timet Sequent the values of d J after the statemi +2 ted the tenth time (A state valid and is read Ch 9: as the new wave of Jequals the old watue of plus one or, equivalently, the Collectio value of Jis to be replacedby the walue Jplus one) 2. Consider the sect of a flowchart shown in Figure A-23. It Ch 10: Understanding hat an absent-minded person is going to work. This individual usually Abstract Llass keys but nally forgets them. Does the flowchart section Figure 23 ethicient method of representing the actio to be taken? not, redraw the flowchart portioa given Figure A-23. Databases Using Ch12: Utilizing Servlets law:harting and i. In the flowchart shown in Figure A-24. what values ofiand I are printed when the output symbol is executed for the fiftieth tim An opaque amonds four rubies, and two pearls. flowdhart that des bes the followin Take a get from the urm. If it is a diamood layit aside. If it is not a diamond, return ta all the dia ds have been removed. After all the diamonds have been removed, repeat the sam Start filling up yo book procedure until all the rubies have been removed. After all the have been removed, continue in the same tasbion until all the pearls have nd notes unlocks been removed. 5. In the flowchart represented by Figure A-25, what are the values ofland the instant the terminal symbol with the word End is reached H APP 18 Java Programming: Comprehensiva concapts and Techniques, 3e n thing

Explanation / Answer

q-1

starting value of j=4 and i=1

after that the update in j and i is made in seection x which is the point from where flow goes after it updates i indicated by x

and in every iteration(repetition of code) update is j=j+1 and i=i+2

first iteration: j=5 (// j=j+1 and j was 4 so j=4+1=5 )

i=3 (// i=i+2 and i was 1 so i= 1+2=3)

similarly second iteration : j=6 and i=5 (since last value of j and i were 5 and 3 respectively)

similarly other iterations:

third iteration: j=7 and i=7 (last values of j and i were 6 and 5 respectively)

fourth iteration: j=8 and i=9 (last values of j and i were 7 and 7 respectively)

now the fifth iteration for which it is asked the value of j and i just after execution j=j+1 i.e. values when i=i+2 is not executed

thus

fifth iteration : j=j+1 gives j=9 (since value of j was 8)

so answer becomes j=9 and i=9 just after execution of j=j+1 (ie. j is updated to new value but i is same as before, since i=i+2 is after j=j+1 so its still not executed. )

fifth iteration i=i+2 gives i=11 (since last value of i was 9)

sixth iteration: j=10 and i=13 (since last value of j and i were 9 and 11 respectively)

seventh iteration: j=11 and i=15 (since last value of j and i were 10 and 13 respectively)

eigth iteration: j=12 and i=17 (since last value of j and i were 11 and 15 respectively)

ninth iteration : j=13 and i=19 (since last value of j and i were 12 and 17 respectively)

now tenth iteration for which we have to tell the value of j and i after execution of i=i+1 ie both i and j are updated

tenth iteration: j=j+1 gives j=14(since last value of j was 13)

i=i+2 gives i=21(since last value of i was 19)

so the answer is j=14 and i=21 after 10th iteration ie. i=i+2 is executed 10th time both are updated since i=i+2 is after j has already been updated ie j=j+1 is already executed

Answers:

i) value of i and j after statement j=j+1 is executed for fifth time

i=9 and j=9

ii) value of i and j after statement i=i+2 is executed for tenth time

i=21 and j=14