Visual Basic Final Spring 2005 (Dr. A.
Ebrahimi)
To answer the questions, work with the Visual Basic .Net environment and paste all of your answers (forms and code) into a Word document to print out. (Use Alt + Print Screen to copy forms when program is running)
To receive complete points answer each part separately.
Q1a)What is wrong with the following average program?
dim x as integer
dim count as integer
dim avg as single
sum= 0
count=1
while x<>9999
x=inputbox("ENTER A NUMBER")
sum=sum+x
count = count + 1
end while
if count > = 0 then
avg = sum / count
else
msgbox (" ERROR IN COUNT " )
endif
Q1b) Fix the above problem and run the program
Q1c) What is wrong with the following search program?
dim id( ) as integer ={1234, 4567,8901,2468,1357,9764}
dim i,key as integer
for i=1 to id.length-1
key=inputbox("ENTER THE SEARCH KEY")
if (key=id(i) then
msgbox ("ID FOUND IN LOCATION" & i)
else
msgbox(" ID IS NOT LISTED")
end if
next
Q1d) Fix the above problem and run the program.
Q2a) Design a payroll
system form with the following controls:
firstname, lastname, hoursworked, hourlyrate, overtimehour, regularpay,
overtimepay and commandbutton. (name
form as your first name and last
name)
Q2b) Write a program
to compute overtimepay, regularpay
and grosspay.
Q3a) Extend your
payroll system form to include:
taxrate, grosspay, taxamount and netpay.
Q3b) Compute taxrate
according to the following:
If gross > 500 taxrate 0.30
gross > 300 then 20%
else 10%
Q4a) Read the form
into the array of size five. For simplicity just compute grosspay
for five employee.
Q4b) Search the
employee last name and display all other information into the form.
Q5a) Compute grosspay from a form and write the form into a file called
employee.dat.
Q5b) Search for
employee last name and display all other information into the form.
Extra credit
Q6a) Create a access
data base with the four fields: firstname, lastname,
hoursworked
and hourlyrate.
Q6b) Create a form
with a data base control and those five fields. One for grosspay.
Q6c) Show how the
data base control connects to the access.
Q6d) Compute grosspay and display on the form.