The File Name Should Be - .PDF: Please Read The Assignments Carefully
The File Name Should Be - .PDF: Please Read The Assignments Carefully
(Please write your name, class roll no., registration no. with year, subject name and page no. on
every page.
Please send the scanned copy (.pdf file) of the answer-script through e-mail. The file name
should be <yourname>_<class roll no>.pdf)
1. Each admitted student in a residential institute will register in a Hostel Management System
with information like First name, Last name, Contact address, mobile number, email address,
Department, Course, PG/UG, Contact’s name and mobile number in case of emergency etc.
Each student will be provided with a unique id and the system will keep track of each student
with this unique id. Each hostel is equipped with MESS department. Students have to pay
extra charge for food bills in the MESS. A student can perform the following tasks in a
Hostel Management System –
2. Define a class Point in C++ that has three members indicating its x, y and z coordinates. The
class Point must have appropriate constructors. Also, write appropriate methods to overload
the following operators:
(i) “+” operator
(ii) “-” operator
(iii) “=” operator
(iv) “>” operator to check if P1(x1, y1, z1) is greater than P2(x2, y2, z2) in a
Cartesian coordinate system
(v) “==” operator for equality comparison
(vi) “<<” operator for displaying point object in “(x, y, z)” form where ‘x’, ‘y’, ‘z’
represent x, y and z coordinates of the point respectively.
Write a main() function to test the above mentioned operators.
3. (a)Write a Java program to add two 3x2 matrices (“a” and “b”) of integers and print the
matrix, which is the sum of “a” and “b”. Initialize the elements of the matrix “a” by the
following formula: a[i][j] = i + j; Initialize the elements of the matrix “b” by the formula
b[i][j] = i*j;
(b) Write a Java program to display prime numbers between lower range and upper range.
Lower range and upper range are supplied by user as command-line arguments.
4. Develop an abstract class “GeometricObject” which has two variables “colour” and
“weight”; it would have a constructor function for setting the “colour” as “white” and the
“weight” as 1.0 as default values. The class should have methods getColour() and
getWeight() to return the colour and weight values to the caller. The class should have two
abstract methods findArea() and findCircumference().
Write subclasses of “GeometricObject” called “Triangle”, “Circle”. Rewrite the methods for
calculating area and circumference of a “traiangle” or a “circle”.