You are on page 1of 4

ASSIGNMENT -2

(1) A book shop maintains the inventory of books that are being sold at the shop. The list includes
details such as author, title, price, publisher and stock position. Whenever a customer wants a
book, the sales person inputs the title and author and the system searches the list and displays
whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the
system displays the book details and requests for the number of copies required. If the
requested copies are available, the total cost of the required copies is displayed, otherwise the
message “Sorry! These many copies are not in stock” is displayed.
Design a system (program) using a class called stock with suitable member functions and
constructors.
(2) Write a program to print the score board of a cricket match in real time. The display should
contain the batsman’s name, runs scored, indication if out, mode by which out, bowler’s score
(overs played, maiden overs, runs given, wickets taken). As and when a ball is thrown, the
score should be updated.

(Hint: Use separate arrays to store batsmen’s and bowlers’ information)

(3) Write a program to prepare the invoice from the following data:
Customer number, customer name, customer address, date of sale, item no, item description,
quantity sold, unit price of item, discount percentage, sales tax percentage.

Note: Identify different classes possible here and make sure that the date of sale becomes equal to
today’s date as soon as object is created. Today’s date should be accepted from user, over in
beginning.

(4) Assume that a bank maintains two kinds of accounts for customers, one called as savings
account and the other as current account. The saving account provides compound interest ad
withdrawal facilities but not cheque book facility. The current account provides cheque book facility
but no interest. Current account holders should also maintains a minimum balance and if the
balance falls below this level, a service charge is imposed. Create a class Account that stores
customer name, account number and opening balance. From this derive the classes Current and
Saving to make them more specific to their requirements. Include necessary member functions in
order to achieve the following tasks:

(i) deposit an amount for a customer and update the balance


(ii) display the account details
(iii)compute and deposit interest
(iv) withdraw amount for a customer after checking the balance and update the balance.
(v) check for the minimum balance (for current account holders), impose penalty, if necessary, and
update the balance.
Implement these without using any constructor.

(5) Write a program to execute the following function in c++.

Assignment -2 [Mrs. Chetna Shah – Maharaja Agrasen Vidyalaya]


(i) Write a user defined function to read the content from a text file NOTES.TXT, count and display
the number of blank spaces present in it.

(ii) Assuming a binary file FUN.DAT is containing objects belonging to a class LAUGHTER (as
defined below). Write a user defined function in C++ to add more objects belonging to class
LAUGHTER at the bottom of it.

class LAUGHTER

intIdno //Identification number

char Type[5]; //LAUGHTER Type

charDesc[255]; //Description

public:

voidNewentry()

{ cin>>Idno;

gets(Type);

gets(Desc);

Void Showscreen()

{ cout<<Idno<<":"<<Type<<endl<<Desc<<endl; }

};

(6) Imagine a publishing company that markets both books and audio-cassette versions of its
works. Create a class publication that stores the title (a string) ad price (type float) of a publication.
From this class derive two classes: book, which adds a page count (type int); and tape, which adds
a playing time in minutes (type float). Each of these three classes should have a getdata() function
to get its data from the user at the keyboard, and a putdata()function to display its data. Write a
main() program to test the book and tape classes by creating instances of them, asking the user to
fill in their data with getdata(), and then displaying the data with putdata().

(7) Assume that a bank maintains two kinds of accounts for customers, one called as savings
account and the other as current account. The saving account provides compound interest ad
withdrawal facilities but not cheque book facility. The current account provides cheque book facility
but no interest. Current account holders should also maintains a minimum balance and if the
balance falls below this level, a service charge is imposed.

Assignment -2 [Mrs. Chetna Shah – Maharaja Agrasen Vidyalaya]


Create a class Account that stores customer name, account number and opening balance. From
this derive the classes Current and Saving to make them more specific to their requirements.
Include necessary member functions in order to achieve the following tasks:
(i) deposit an amount for a customer and update the balance
(ii) display the account details
(iii) compute and deposit interest
(iv) withdraw amount for a customer after checking the balance and update the balance.
(v) check for the minimum balance (for current account holders), impose penalty, if necessary, and
update the balance. Implement these without using any constructor.

(8) Write a PROGRAM in C++ to read the content of a text file "PLACES.TXT" and
display all those lines on screen, which are either starting with 'P' or starting with 'S'.

(9) Write a program that copies one file to another. Has the program to take the file names from the
users? Has the program to refuse copy if there already is a file having the target name?

(10) Write a program that appends the contents of one file to another. Have the program take the
filenames from the user.

(11) Write a program that reads character from the keyboard one by one. All lower case characters
get store inside the file LOWER, all upper case characters get stored inside the file UPPER and all
other characters get stored inside OTHERS.

(12) Write a program to search the name and address of person having age more than 60 in the
data list of persons.

(13)
Write a menu driven program in C++ to perform the following functions on a binary file“BOOK.DAT”
containing objects of the following class :
classBook
{ intBookNo;
charBook_name[20];
};
Create appropriate functions for following operations.

1) Append Records
2) Modify a record for a given book no.
3) Delete a record with a given book no.
4) Search for a record with a given Book name
5) Exit

(14) WAP in c++ to define a class BANK and to perform its basic functions .

class bank { char name[80];


intacc_no;
enumacctype{S,C};
voidaccount_type(int n);

Assignment -2 [Mrs. Chetna Shah – Maharaja Agrasen Vidyalaya]


float balance;
public:
floatadd_bal(float n);
floatwithdrawl (float k);
void initial();
void display();
};

(15) Given a binary file stud.dat containing the records of class student type with the following
specification:
Class student{
int rollno; char name[25]; int m1; int m2; int m3; int total; };
Write a menu driven program in c+ that would perform the following task:
1. Store the details with above specification in the binary file.
2. Display only the details of those students whose percentage is greater than 75%.
3. Count no of records.
4. Exit.

Assignment -2 [Mrs. Chetna Shah – Maharaja Agrasen Vidyalaya]

You might also like