0% found this document useful (0 votes)
18 views1 page

Class Practice-Problems

The document outlines practice problems for creating various classes in programming. It includes tasks for implementing a 3-D vector class with a dot product function, a circle class to check for intersections, an employee class for salary calculation, a student class for storing student details, and a rectangle class to calculate area. Each problem provides hints and specific requirements for implementation.

Uploaded by

alamin shawon
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)
18 views1 page

Class Practice-Problems

The document outlines practice problems for creating various classes in programming. It includes tasks for implementing a 3-D vector class with a dot product function, a circle class to check for intersections, an employee class for salary calculation, a student class for storing student details, and a rectangle class to calculate area. Each problem provides hints and specific requirements for implementation.

Uploaded by

alamin shawon
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/ 1

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.

You might also like