CS99 Fall 2001 Sample Problems 1. Add one to square root of 4. 2. Find the ASCII characters whose integer codes correspond to the integers from 10 to 15. 3. Generate a random number between 5 and 6 4. Enter a string without having to use '' 5. Find the remainder of 17/13. 6. Assign 1 to x. Unassign x. Check the value of x. 7. Clear up the screen and display 'Hello, World!' 8. What are the outputs for the following expressions? 1==1 & 2==2 1>2 | 1<2 xor(1<2, 1<3) 9. In the Gregorian calendar, leap years are determined by the following rules: 1) Years evenly divisble by 400 are leap years 2) Years evenly divisible by 100 but not by 400 are not leap years 3) all years divisible by 4 but not by 100 are leap years 4) all other years are not leap years Write a program that prompts the user to enter a year and check if it is a leap year according the above rules. Report the result. 10.Write a program to read in a numerical grade and assign a letter grade to it according to the following rules: 1) grade > 95 A 2) 95>= grade > 86 B 3) 86>= grade > 76 C 4) 76>= grade > 66 D 5) 66>= grade > 0 F 11.Write a program that asks the user for a name with 3 letters. Your program should store the name in a variable called $name$. The program should output whether the name that the user typed in is: in upper case (e.g. TOM), or in lower case (e.g. tom), or in title case (e.g. Tom), or in messy case, which is non of the above (e.g. ToM, TOm, tOm, ...). Some help on how to deal with strings: Imagine you have a string assigned to a variable, e.g. var='Jen' There is a Matlab function called $double$ that converts a string into an array of numbers where each number represents the position of the according letter in the table of ASCII values. Here is a small portion of the table of ASCII values: letter position letter position A 65 a 97 B 66 b 98 C 67 c 99 D 68 d 100 E 69 e 101 F 70 f 102 ... ... ... ... U 85 u V 86 v 118 W 87 w 119 X 88 x 120 Y 89 y 121 Z 90 z 122 If you typed name=double('Jen') in the Command Window then an array containing 3 numbers: 74 101 110 would be stored in w. For simplicity, you can assume that any letter that is not uppercase (position 65 through 90) is lower case.