REALBasic Beginning Exercises
Exercise 1:
Given the following variables names:
myName, friendsName, mySong, friendsSong
assign your name to the variable myName and your friend's name to friendsName.
Then assign your favorite song to mySong and a favorite song for friendsSong.
Display myName, friendsName, mySong, and friendsSong in statictext1 through statictext 4.
Don't forget to Dim the variables
*******************************************************************************************
Exercise 2:
Calculate the average grade of three test scores.
Given the following variable names how would you solve this problem in REALBasic code:
test1, test2, test2 and avgTestScore
test1 = 80
test2 = 90
test3 = 65
//in code how would you calculate the the average test score and
//display it's value in a statictext field
// in REALbasic is a comment - non-executable code
Don't forget to Dim the variables
**************************************************************************
Exercise 3:
First on a piece of paper answer the following Questions:
What is the value of grades - if studentName = “Jerry”
What is the value of grades if studentName = "Harry"
Dim studentName as String
Dim grades, gradesTom, gradesJerry, gradesHarry as Integer
grades = 0
gradesTom = 80
gradesJerry = 100
gradesHarry = 50
if (studentName = “Tom”) thengrades = gradesTom
elseif (studentName = "Jerry") then
grades = gradesJerry
elsegrades = gradesHarry
end ifStaticText1.text = str(grades)
*******************************************************************************************
Do Exercise 3 on the computer
First add a Pushbutton
Add the above code in the Pushbutton Action method
add a textfield where the user will enter a name of either Tom, Jerry or Harry
add a Statictext field where the grade will be displayed
Do you get the predicted answers?