Lab 07. CS100J Spring 08. Practice with assertions and loopsGoal of this labPractice with assertions and loops that process a range of integers. Part of this lab is done on paper.1. Question on ranges:How many values are in the following ranges? The last one requires a formula in terms of h and k. Remember: in the notation h..k, we require k h–1. For example, 5..4 is OK but 5..3 is not allowed.≥a)5..62(d) h..h1b)5..51(e) h..h–10c)5..40(f) h..kk+1-h2. Each line below asks you to write an assignment. We did the first one for you.RangeWantAssignment(a) h..kAssign to k so that the range has 1 element:k= h;(b)h..kAssign to h so that the range has 1 element:h= k:(c)h..kAssign to k so that the range has 0 elements:k=h-1;(d)h..k Assign to h so that the range has 0 elements:h= k+1;(e)0..n–1 Assign to n so that the range has 1 element:n= 0;(f)0..n–1Assign to n so that the range has 0 elements:n= -1;(g)h–1..10Assign to h so that the range has 1 element:h= 11;(h)h+1..10Assign to h to that the range has 0 elements:h=10;3. Each line below contains an assertion P, which we know is true. Each line also contains an assertion R, which we would like to be true. In the righthand column, put a Boolean expression that, when true, allows us to conclude that R is true. We have filled in the first one for you.KNOW P:WANT R:Additional info needed(a)x is the sum of 1..nx is the sum of 1..100n == 100(b)x is the sum of 1. (n–1)x is the sum of 1..100n==101(c)x is smallest char in s[0..k–1]x is smallest char in s[0..s.length()–1]

This
preview
has intentionally blurred sections.
Sign up to view the full version.