C++ Complex program


1.Write a necessary class & member function definition for a cricket player object.(Use array of objects)
The program should accept the details from user (max 10):
Player code, name, runs, innings- played and number of times not out.
The program should contain following menu:
-Enter details of players.
-Display average runs of a single player.
-Display average runs of all players.(Use function overloading).

2. Write a necessary class to calculate variance &standard deviation of n numbers.
Variance = 1/N ? (Xi-A.M.)2 for all i = 1 to N S.D. =variance
Where A.M. = 1/N ? X for all i = 1 to N

3. Create a class phone having data members:
1. The STD code
2. The Exchange code
3.Phone Number
Ex :- 212-766-8901
Write a C++ program to accept details from user (max 10) and change input
phone number to new phone number using following criteria:
a)Add 1 to 1st digit of STD code. (If digit is 9 it becomes 10)
b)The exchange code is retained as it is.
c)In 3rd part of structure, 1st two digits should be reversed.
Ex: I/P : 212-766-890 => O/P : 312-766-980
Display all changed phone numbers.

6. Define a class to represent a bank account which includes following members :
Data members –
1)Name
2)Account number
3)Type of account
4)Bal. amt
Member functions –
a.To assign initial value
b.To deposit an account
c.To withdraw an account
d.To display name, account number & balance.

7. An electricity board charges the following rates to users
– For first 100 units : 40p per unit
– For next 200 units : 50p per unit
– Beyond 300 units : 60p per unit
All users are charged a minimum of Rs.150. If the total cost is more than Rs.250.00 then an additional charges of 15% are added.
Write a C++ program using class to read the name of users & number of units consumed & print out the charges with names.(Use Array of Objects)

9. Imagine a tollbooth at a bridge. A Car passing by the booth is expected to pay a toll. The tollbooth keeps the track of the number of cars that gone by and the total amount of cash collected.
Create a class tollbooth with the data members as:-
-total number of cars passed.
-total toll collected.
Write necessary member functions:
1. a constructors that initializes both data members to zero.
2. paying car(): when any car passes through the tollbooth,that much toll gets added into total toll collected and total number of cars passed is incremented by one.
3. nonpaying car(): increments the car total but adds nothing to cash total.
4. display (): displays total no. of cars passed and the total amount collected.

11. Create a class student containing data members:
– Rollno
– name
-marks1, marks2, marks3
Write necessary member functions:
1. to accept details of all students
2. to display details of one student
3. to display details of all students(Use Function overloading).

13. Create a C++ class for student having following members.
– Rollno
– Name
– Number of subjects
– Marks of each subject
(Number of subjects varies for each student)
Write a parameterized constructor which initializes rollno,name & Number of subjects and creates the array of marks dynamically. Display the details of all students with percentage and class obtained.

14. Create a C++ class Date which contains:
– day
– month
– year
Write necessary member functions to accept and display a date using >> and << operators.

15. Create a class Array which contains
– int *ptr
– int n
Write a menu driven program :
– to Accept an array from user
– to display it.
– to add two arrays using operator overloading.
– to subtract two arrays using operator overloading.

16. Create a class vector that contains series of n numbers.Perform the Pre-Increment and Post- Decrement operations on a vector object using operator overloading.(Use friend Function).

17. Create a class Time which contains:
– hours
– minutes
– second
Write a C++ program using operator overloading for the following:
1. = = to check whether two Times are same or not.
2. >> to accept the time.
3. << to display the time .

18. Create a class string which contain a character pointer.write a c++ program to overload following operater :
1. < to compair two string (using new operater)
2. != to check equality two string.

21. Create a class currency containing rupees and paise as data members. Write necessary member functions using operator overloading for the following:
1.currency (long int rup=0,int paise=0)
2.currency & operator += (currency &)(to add one currency to another)
3.currency & operator – = (currency &)(to subtract one currency from another)
Accept Rupee & paise from user and display it.
22. Consider a class point containing x and y coordinates.Write necessary functions for the following cases:
1. to accept a point
2. to display it
3. to find distance between two points using operator overloading (-)(Use friend function).

23. Write a program to read the contents from the file“sample.txt”. Store all the characters from “sample.txt”into the file “character.txt” & store all digits into the file “digit.txt “.

24. Create a class Student having data members:
– RollNo
– Name
– Marks
Write necessary member functions :
1. to accept the details and store it into the file “school.dat”
2. to read the details from file and display it.
3. to update a given record into the file.

26. Degsign two base personnel(name, address,e-mail-id,birthdate)and academic (marks in 10th and 12th,class obtain) derive a class biodata from both these class.write a c++ program to prepare a biodata of a student having a personal information and academic information.

28. In a bank, different customers having saving account. Some customers may have taken a loan from the bank. So bank always maintains information about bank depositors and borrowers. Design a Baseclass Customer (name, phone-number).Derive a class Depositor(accno, balance)from Customer. Again derive a class Borrower (loan-no, loan-amt) from Depositor.Write necessary member functions to read and display the details of ‘n’ customers.

30. Consider the following class hierarchy.create a base class employee (empcode emp name). Derive the class manager (designation clubdues),scientist(department name ,publication) and labourer from employee class.write C++ menu deriven program
1.To accept the detail of ‘n’ employee.
2. To display the information.
3.To display all the scientist from “chem department”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s