1.
Add one to the 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 have the user use single
quotes. See Lab 2.
5.
Find the remainder of 17/13.
6.
Write MATLAB code that
I.
Assigns 1 to x.
II.
Un-assigns x.
III.
Checks the value of x.
7.
Clear up the screen and display 'Hello,
World!'
8.
What are the outputs for the following expressions?
I.
1==1 & 2==2
II.
1>2 | 1<2
III.
xor(1<2, 1<3)
9.
In the Gregorian calendar, leap years are determined by the
following rules:
1)
Years evenly divisible 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 none 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
117
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 variable name.
For simplicity, you can assume that any letter that is not uppercase (position 65
through 90)
is lower case.