Practice Problems on Class
1. Create a 3-D vector class where the coordinates indicate the x, y and z components of the
vectors. Write a function to calculate the dot product of two vectors.
Hint: vector in a 3-D plane can be represented by three coordinates say 2,3,4
The dot product of two vectors A = 2x+3y+4z and B = -2x-3y-4z would be 2*(-2) +3*(-3)+4*(-
4)
No need to use the point class
2. Create a circle class where the center is indicated by the point class shown in class before.
Create a member variable radius. Ask the user to provide the center coordinates and the radius
of the circles. Your task is to identify if the two circles intersects or not.
Hint: Calculate the distance between the centers of the two circles, compare against the sum of the
radiuses.
3. Create an employee class with an id, salary and hours-worked as the member variables. Create
member functions to calculate the salary based on hours-worked and a payment rate of 100
BDT per hour.
4. Assign and print the roll number, phone number and address of two students having names
"Maria" and "Asima" respectively by creating two objects of the class 'Student'
5. Write a program to print the area of two rectangles having sides (4,5) and (5,8) respectively by
creating a class named 'Rectangle' with a function named 'Area' which returns the area. Length
and breadth are passed as parameters to its constructor.