%Variables used in program
var firstname : string
var lastname : string
var age, a,b : int
var yn : string
var myage : int
var myfname: array 1..5 of string:=init ("Josh", "Adam", "Michael", "Steve", "Joanne")
var mylname: array 1..5 of string:=init ("Smith", "Johnson", "Michaels", "Hanks", "MacDonald")
randint (a, 1, 5)
randint (b, 1, 5)
%Random for age
randomize
randint (myage, 5, 30)
%Get first name
put "Hello my first name is ", myfname(a), "."
put "What is your first name?"
get firstname
%Get last name
put "My last name is ", mylname(b), "."
put "What is your last name?"
get lastname
%Get age
put "I am ", myage, " years old"
put "How old are you?"
get age
%Verify
put "Let me see if I got this right."
put "Your name is ", firstname
put "Your last name is ", lastname
put "and you are ", age, " years old."
put "is this correct? (y/n)"
get yn
%Make comparison
if yn = "y" or yn = "Y" then
if age = myage then
put "We are the same age!!!!"
end if
if age > myage then
put "You are ", age - myage, " years older then me!!"
end if
if age < myage then
put "You are ", myage - age, " years younger then me!!"
end if
end if
if yn = "n" then
put "oh sorry i guess we better start again."
end if
if myfname(a) = firstname and mylname(b) = lastname then
put "What a coincidence, you an I have the same first and last name!!!"
end if
if myfname(a) = firstname and mylname(b) not= lastname then
put "Hey, we have the same first name"
end if
if mylname(b) = lastname and myfname(a) not= firstname then
put "Hey we have the same last name"
end if
|