Class: remember - because Dr. Knapp and I are designing our tests together, the test this term may be substantially different from this. Also note that topics covered on this test may be somewhat different than what you will see. Introduction to Programming Sample Test 1 1. (8 points) Write the exact output (use _ for a blank space) for the following segment: VAR Output val1 : REAL; num1, num2 : INTEGER; BEGIN val1 := 45.678; num1 := 762; num2 := 223; write ( val1:7:2 ); writeln ( num1:5 ); writeln ( num2:2 ) END. 2. (12 points) Assume "grade" is an INTEGER variable. Write a compound IF statement that will determine whether the grade is good (9 or 10), bad (5 or 6) or other (anything else). If the grade is a good grade, increment (add 1 to) the variable good_count and print a message such as "10 is a good grade." Increment the variable bad_count or other_count, as appropriate, for bad or other grades. For bad grades, also print out an appropriate message such as "5 is a bad grade." You may assume that the count variables have been defined as INTEGER variables. 3. (12 points) Rewrite your answer to question 2 using a CASE statement. 4. (8 points) Determine the output from the following segment: number := 11; Output IF number >= 3 THEN number := number - 3 ELSE IF number >= 2 THEN number := number - 2 ELSE number := number -1; writeln ( number ) 5. (28 points) Assume the following definitions and assignments: VAR i1, i2 : INTEGER; s1, s2 : string[50]; b1, b2 : BOOLEAN; i1 := 40; i2 := 6; s1 := 'alphabet soup'; s2 := 'string50'; b1 := TRUE; b2 := FALSE; Indicate the value of each of the following expressions: a) i1 mod i2 b) s2 + s1 c) i1 / 12 d) 2 * 3 + 4 * 5 e) (i2 < 100) f) (b1 AND b2) g) b2 = b2 OR b1 6. (12 points) Write a complete Turbo Pascal v. 7 program that will ask you to enter your name, and then will say hello to you, as in: Enter your name: Bennette Hello, Bennette. 7. (20 points) Complete the following program which will convert an entered number of days into weeks and leftover days. Your program should be able to produce the sample dialogue as shown: Enter the number of days: 45 NOTE: If you cannot write the 45 days is 6 weeks and 3 days. entire program, then write the parts you can. PROGRAM weeks; USES crt; CONST days_per_week = 7; VAR entered_days, weeks, leftover_days : INTEGER; BEGIN { weeks } END. { weeks }