0% found this document useful (0 votes)
5 views

Tutorial Programming 2 & OOP-Copy

The document is a tutorial sheet for a Programming 2 and Object-Oriented Programming course, outlining key concepts in OOP, including definitions and examples of terms like inheritance and polymorphism. It includes programming exercises and minor projects that cover various programming tasks in VB.NET, such as matrix operations, string manipulation, and creating classes. The sheet serves as a study guide to help students prepare for exams.

Uploaded by

arthurtsapi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Tutorial Programming 2 & OOP-Copy

The document is a tutorial sheet for a Programming 2 and Object-Oriented Programming course, outlining key concepts in OOP, including definitions and examples of terms like inheritance and polymorphism. It includes programming exercises and minor projects that cover various programming tasks in VB.NET, such as matrix operations, string manipulation, and creating classes. The sheet serves as a study guide to help students prepare for exams.

Uploaded by

arthurtsapi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COURSE

Programming 2 & Object-Oriented Programming


TUTORIAL SHEET

SECTION 1: SUMMARY OF THE NOTES

1. Define the following terms as used in OOP with examples.


- Inheritance
- Polymorphism
- Method Overloading
- Constructor Overloading
- Abstraction
- Encapsulation
- Polymorphism
- Class
- Methods
- Object
- Access Modifiers

2. List 5 datatypes VB.NET uses.


3. List 4 differences between Visual Basic and Visual Basic.NET
4. Give the steps to create a VB.NET Project in Microsoft Visual Studio 2010.
5. With the help of an example differentiate between a property & a method within a Class.
6. List 10 reserved keywords in VB.NET
7. With the help of one example each, write codes for the following

- Do.. while loop


- For ….. next loop
- While loop
- Foreach loop
- With … end loop

OOP Tutorial Sheet - Page 1|4


SECTION 2: WRITE A PROGRAM TO PERFORM THE FOLLOWING

1. Program to add two matrices A and B


2. Program to check if a character input by the user is a vowel or not.
3. Program to check if a given number is an Armstrong number
4. Program to compare two strings
5. Create an application that will ask for a circle's radius. Then print its circumference and its area.
Program to calculate the area of a triangle using hero’s formula
6. Program to calculate the area of a square and circumference of a circle
7. Program to show call by value
8. Program to show call by reference
9. Program to check if a number if a palindrome. A palindrome is a word which when
written in reverse order remains the same. Example: CIVIC, RADAR, LEVEL, REFER
10. Program to take a string and display it in reverse order
11. Program to print all numbers between 0-100 which are divisible by 3 and 5
12. Program to print first n prime numbers
13. Program to multiply two matrices
14. Program to display the Fibonacci series using recursion
15. Program to find the value of sin(x) using exponential series

OOP Tutorial Sheet - Page 2|4


SECTION 3 – MINOR PROJECTS:
1. A year is a leap year if it is divisible by 4 unless it is a century year (one that ends in 00)
in which case it has to be divisible by 400. Write a program to read in a year and report
whether it is a leap year or not.
2. Build a number guessing game that uses input validation (isdigit() function) to verify that
the user has entered a digit and not a non-digit (letter). Store a random number between 1
and 10 into a variable each time the program is run. Prompt the user to guess a number
between 1 and 10 and alert the user if he was correct or not.
3. Write a program to display the message “God is love!” 100000 times. The program
should allow users to terminate the execution at any time by pressing any key before it
display all the 100000 messages.

4. Let’s consider the following algorithm to calculate the product of two numbers:

𝑎 ∗ (𝑏 − 1) + 𝑎 𝑖𝑓 𝑏 𝑖𝑠 𝑜𝑑𝑑
𝑎∗𝑏 ={ 𝑏
(2 ∗ 𝑎) ∗ ( ) 𝑖𝑓𝑏 𝑖𝑠 𝑒𝑣𝑒𝑛 𝑎𝑛𝑑 𝑏 ≠ 0
2
a) Write a recursive function which calculate the product of two numbers according to the
above algorithm.
b) Write an iterative function which calculate the product of two numbers according to the
above algorithm.
c) For each function defined above, write a main program using it to calculate the product of
two integers entered by the user.
d) Write an iterative program to calculate the product of two numbers using the above
algorithm and print the result as shown in the following example:

5. Write a function which generate 50 integers between 1 and 100 randomly and do the
follow. It calculates the factorial of each number divisible by 5 of and the inverse of each
number divisible by 6. You must use two functions facto and inverse to calculate the
factorial and the inverse of any number. Static variables should be used in those functions
to count the number of time each of them has been called.

6. Build a program that uses a single-dimension array to store 10 numbers input by a user.
After inputting the numbers, the user should see a menu with two options to sort and print
the 10 numbers in ascending or descending order.

7. Write a calculator class which will accept two values as arguments, has 4 methods (add,
subtract, multiply and divide). Test the above class with the values 10 and 5.

OOP Tutorial Sheet - Page 3|4


8. Create a class Person and 2 getters and setters methods called setName and getName. Set
the name of the person called JONES and display it.

GOOD LUCK AS YOU PREPARE FOR YOUR EXAMS

OOP Tutorial Sheet - Page 4|4

You might also like