Assignment 1
Assignment 1
NB: VB.net automatically creates folders with names that you save your work with (in my documents), in this course
you are required to submit ONLY running projects. NO PDF OR WORD documents will be accepted, submission
of these is an automatic zero. Number your work (projects) copy all the folders into one folder you shall save with
your Pin Number zip it and submit. It remains the responsibility of the student to submit running /compiling
projects. If it can compile on your machine, it should be able to compile on my machine as well.
Question 1
a) Design a simple user interface that enables a user to enter variable for price of a purchased item and
apply constant discounts of 10%, 20% and 30% respectively on click of a Calculate button. Use locked
and disabled textboxes for output, with a fixed single property as well. Results of the calculation are
displayed in text boxes. The overall outlook of the interface should look as follows:
[8]
b) Write appropriate code to be executed on button click event of the Calculate and Exit buttons
respectively. Marks are awarded for a well commented and validated program. [12]
Question 2
a) Use an if statement to write a program that asks a user to enter their location and tell them the current
weather at that location for the following:
i. Mutare – Thunderstorm
ii. Harare - Sunny
iii. Bulawayo – Cold
iv. Gweru – Drizzle
v. Other - Unknown [10]
b) Rewrite the same program in a) using a Select Case Statement. [10]
Question 3
A quality control inspector tests ovens by setting them to 200oC and then measuring the actual temperature inside
the oven 5 times at 10minute intervals. Write a program that inputs the 5 measurements and then prints the
following in relevant labels:
i. the average measurement
ii. the minimum temperature
iii. the maximum temperature
during the test period. [20]
Question 4
a) Write a program that requests a month of the year then displays the number of days in the month. If the
month is February, the user should be asked whether the current year is a leap year. Use Select Case
construct for determining the number of days in the month. [10]
b) Working with arrays, write a program that accepts a set of test marks between 0 and 100 for a class of 10
students. The marks should be integers. The program should compute the average, lowest and highest
marks in the test. [12]
c) Write a program that determines whether a given integer is prime or not. The program should display an
appropriate message after the check. [8]
d) Write a program that determines and display the number of odd numbers between 1 and 50. [8]