You are on page 1of 7

FUNDAMENTALS OF OOP ASSIGNMENT 1

Question 1:
Write a code on the button named cmdCount that will accept an integer from the user as input entered
in a textbox named txtNum and then determine how many digits in that integer are threes and display
the result in the label named lblResult. Also write code in the button named cmdExit that close the
program. As shown in the following sample runs:

txtNum

cmdCount cmdExit

lblResult

Question 2:
A local shipping company needs a program to calculate the shipping charges for packages brought in by
the customers. The shipping charge is 0.15 cents per ounce. The input to the program is how much the
package weighs in pounds and ounces (two separate inputs - for example, if the package weighs 8 pounds
and 6 ounces then the total weighs in ounces is 134). (Note: 1Pound=16 Ounces).

i) Write code on the button named cmdCalc that takes the weights of the package as an input
entered in textboxes named txtPounds and txtOunces and calculate the total weights in
ounces and display the total weights in a label named lblTotOz. The code should also calculate
the cost of shipping the package and displays the cost in the label named lblShipCost.

ii) Write code on the button named cmdClear that clears (delete) data in the textboxes (named
txtPounds and txtOunces) and the labels (named lblShipCost and lblTotOz) so that the user of
the program can insert another weighs for another package and displays new results in the
labels. Also write code in the button named cmdExit that close the program.

1
A sample run of the program should look something like the following:

txtPounds txtOunces

lblShipCost
lblTotOz

cmdCalc cmdClear cmdExit

Question 3:
The Edsel Car Rental Company rents Edsels for $35 per day plus 0.10 cents a mile. The company needs a
rent-a-car program which allows the clerk to enter the date that the car was rented, the date that the car
was returned, the mileage when the car was rented, and the mileage when the car was returned.

a) The program should calculate the following: (Write a code in the button named cmdCalculate)

i.
Number of days the car was rented and displays the results in lblDays.
ii.
Total cost for number of days the car wa rented and displays the results in lblDayTot.
iii.
Mileage used by the customer and displays the results in lblMiles.
iv.Total cost for the number of mileage used by the customer and displays the results in
lblMileTot.
v. Total charges and displays the results in lblTotDue.
(Note: Use the DateDiff function to determine the number of days that the car was rented).

b) Write code on the button named cmdClear that clears (delete) data in the textboxes (named
txtDateRented, txtDateReturned, txtStartingMileage and txtEndingMileage) and the labels
(named lblDays, lblMiles, lblDayTot, lblMileTot and lblTotDue) so that the clerk can insert another
weighs for another package and displays new results in the labels. Also write code in the button
named cmdExit that close the program.

A sample run of the rent-a-car program should look something like the following:

2
txtDateRented
txtDateRented

txtDateReturned
txtDateReturned

txtStartingMileage

txtEndingMileage

lblDays lblDayTot

lblMiles lblMileTot

lblTotDue

cmdCalculate cmdClear cmdExit

Question 4:

(a) Write code on the Deposit button that will take specified deposit amount displayed on the textbox
named inputTextBox and then add to the existing balance and display new account balance on
the label named lblAccountBalance. The code should be capable of increasing the balance
everytime the user deposit new amount. As shown in the sample output below:

inputTextBox

lblAccountBalance

3
(b) Write code on the Withdraw button that will take specified withdrawal amount displayed on the
textbox named inputTextBox and then subtract from the existing and display new account
balance on the label named lblAccountBalance. The code should be capable of decreasing the
balance everytime the user withdraw new amount. As shown in the sample output below:

inputTextBox

lblAccountBalance

Question 5:

Write code on the command button named Test that determines whether or not a word or phrase input
by the user in the textbox is a palindrome (a word that is spelled the same way both forwards and
backwards). For example, the program should be able to tell that words like "RADAR" and "DEED" are
palindromes. Display the result in the label named results. Sample test is as shown below:

Question 6:
Given the form design below:

4
txtFirst

txtLast
txtFullname

btnShowname

Write the code that displays Full name in the “txtFullname” textbox when user enters firstname in
“txtFirst” textbox and lastname in the “txtLast” textbox and click Show full name.

Question 7:
Given the following form design:

Label1 picLogo

btnShow btnLogo

When User click on the “btnShow” Button then image below on the left appears and when the user
click on the “btnLogo” Button the image below on the right appears. Write the code on the
appropriate button that makes this happen.

Question 8:

5
Given the form design below:

Write the code to the appropriate button that displays student details which are entered by the user.
Use the message box to display the student details as shown in the sample output below.

Question 9:
Given the form design below:

6
Assume the correct username is Mwalimu and password is Programming. Write code on the
appropriate button that displays a message Login successfully on the message box if both username
and password are correct otherwise it displays try again. As shown in the sample output below:

You might also like