0% found this document useful (0 votes)
17 views3 pages

On Classes - 1

The document outlines a series of programming tasks involving the creation of classes in C++. It includes the development of a computer warehouse class, an employee class, an object-oriented database, a land class for polygons, and various other classes for handling student details, triangles, rectangles, complex numbers, matrices, reports, and movies. Each task specifies the required attributes and methods for the classes, emphasizing object-oriented principles.
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)
17 views3 pages

On Classes - 1

The document outlines a series of programming tasks involving the creation of classes in C++. It includes the development of a computer warehouse class, an employee class, an object-oriented database, a land class for polygons, and various other classes for handling student details, triangles, rectangles, complex numbers, matrices, reports, and movies. Each task specifies the required attributes and methods for the classes, emphasizing object-oriented principles.
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/ 3

WRITE PROGRAMS USING CLASSES

Set 1

1.Create a computer warehouse class in which three types of computer peripherals are stored ,for
selling.

Write a main function which prints how many of each peripheral is sold, what is the total amount
received by sales ,and a message stating whether the month’s target is achieved or not .Note that
every month , many of these items are sold .Develop the code for such a system.

2.Create an employee class in which an employee’s name , identity number , salary and number
of ‘leaves’ available are noted . Write a main function which prints all these for employees.

Note that every year , an increment is given to an employee .Also , when an employee takes leave ,
his ‘net ‘ leave reduces until after a limit ,no more leave can be sanctioned .Appropriate messages
may be given.

Develop the code for such a system.

2.Construct an object oriented data base to carry out the following methods.These actions are to be
done for different data which is given .

i)Build a master table


ii)List a table
iii)Insert a new entry
iv)Edit an entry
v)Search for an record to be printed
vi)Sort entries .

A)Personal Information:

Name
Date of Birth
Blood Group
Height Weight
Contact address
Telephone number

B)Library
Accession Number
Name of the author
Title of the book
Year of Publication
Cost of the book
4. Consider a class of ‘land’ named ‘polygons’ where ‘ area’ and
‘perimeter’ are functions . From this base class ,lands of various shapes
can be derived . It is required to print the charges incurred in building
a fence around a polygon of shape rectangle and also the charges for
laying a lawn in that area. Write a C++ program for this setup.

Set 2
1. Write a program to Read and print details (name, roll no, total marks obtained) of a
student using classes in C++.
2. Write a program to print the area and perimeter of a triangle having sides of 3, 4 and 5
units by creating a class named 'Triangle' with a function to print the area and
perimeter.
3. Write a program to print the area of a rectangle by creating a class named 'Area' having
two functions. First function named as 'setDim' takes the length and breadth of the
rectangle as parameters and the second function named as 'getArea' returns the area of
the rectangle. Length and breadth of the rectangle are entered through keyboard.
4. Print the sum, difference and product of two complex numbers by creating a class
named 'Complex' with separate functions for each operation whose real and imaginary
parts are entered by the user.
5.
Create a class called 'Matrix' containing constructor that initializes the number of rows
and the number of columns of a new Matrix object. The Matrix class has the following
information:

1 - number of rows of matrix

2 - number of columns of matrix

3 - elements of matrix (You can use 2D vector)

The Matrix class has functions for each of the following:

1 - get the number of rows

2 - get the number of columns

3 - set the elements of the matrix at a given position (i,j)

4 - adding two matrices.

5 - multiplying the two matrices

You can assume that the dimensions are correct for the multiplication and addition.

6. Define a class REPORT with the following specification:


Private members :
adno 4 digit admission number
name 20 characters
marks an array of 5 floating point values
average average marks obtained
GETAVG() a function to compute the average obtained in five subject
Public members:
READINFO() function to accept values for adno, name, marks. Invoke the function
GETAVG()
DISPLAYINFO() function to display all data members of report on the screen.
You should give function definitions

7. The class Movie is started below. An instance of class Movie represents a film. This class
has the following three class variables:
● title, which is a Stringrepresenting the title of the movie
● studio, which is a Stringrepresenting the studio that made the movie
● rating, which is a Stringrepresenting the rating of the movie (i.e. PG13, R, etc)

public class Movie {


private String title;
private String studio;
private String rating;
// your code goes here
}

a) Write a constructor for the class Movie, which takes a String representing the title of
the movie, a String representing the studio, and a String representing the rating as its
arguments, and sets the respective class variables to these values.

b) Write a second constructor for the class Movie, which takes a String representing the
title of the movie and a String representing the studio as its arguments, and sets the
respective class variables to these values, while the class variable rating is set to "PG".

c) Write a method getPG, which takes an array of base type Movie as its argument, and
returns a new array of only those movies in the input array with a rating of "PG". You
may assume the input array is full of Movie instances. The returned array need not be
full. d) Write a piece of code that creates an instance of the class Movie with the title
“Casino Royale”, the studio “Eon Productions”, and the rating “PG13”.

You might also like