Vous êtes sur la page 1sur 2

Controlled copy Cognizant In-Campus Training Programme Object Oriented Programming Lab Assignment 1.

. Write a C++ program to implement the department class as follows, * Identify the essential features of department. * Implement destructor and various constructor functions. * Add member functions such as read_details, print_details as read only and modify_details(change the existing state of an object) * Implement various types of object creation, initialization and assignment including array of objects. 2. Write a C++ program to prompt the user for a Train name, source, destination, departure time from source and expected arrival time of a train at destination. Store these details in two Train objects. Define various parameterized constructors to initialize train name, source, destination and current time. Calculate how long the journey takes to reach the destination. Display the following information for various trains. Train Name : ---------Source : ---------Destination : ---------Current Time : xx:xx Departure time: xx:xx Arrival time : xx:xx Journey time x hours x minutes Time requires to reach destination: current time arrival time Write a C++ program to maintain information about Tamilnadu cities and towns. More specifically, each object consists of the name of the town, the county or counties and the city in which it is situated, the year in which it was incorporated, its population as determined by the census of 2004, its area in square kilometers, an estimate of the number of telephones in the town, and the number of radio stations and television stations serving the town. Thus a typical entry reads as follows:
14, 5 Thiruppur, Covai, Tamilnadu, 1991, 331767, 247, 323935,

3.

1. Which of those towns has the highest population density (population divided by area)? 2. Which of these towns has over one million telephones? 3. Which town has the lowest population, number of radio and television stations (together)? 4. Write a C++ program to maintain student objects contain students first and last name and the results of three tests. Your program has to compute the average test score for each student, the maximum and the minimum scores for each test and average (among the students), and prints the results in a formatted table. Program provides facility to display the particular student details by request.
Name Test 3 First Average Last 1 2

Rajiv
94.33 Aravinth . . Maximum Minimum

Balaganesh
Sriram

88

85
99

92

88.33
90 94

-----------

---

---

---

Copyright Cognizant Academy All Rights Reserved

Controlled copy

5. Define the class Senate that contains information about the members of the 2003 2004 University Senate. The data members are the last name, the first name, the district number, the town of residence, the state, and the town's zip code. First Name
Code

Last Name Kasi Masi Mary

District number District Country

Pin

Anand Kalai Lilly

4 3 2

Salem Trichy

TN TN

650801 650265
652302

Madurai TN

Write member function which displays details based on the users choice (List details
senators-by-district or senators-by-zip-code or senators-by-name).

6. Define the class postcard that consists of receiver name, place of receiver, message and sender name. Write the definition (including two constructors) for the Postcard class. One constructor should be a default constructor and the other should take three strings as its parameters. Write a main function to create and print two postcards. One should be a card created with the default constructor and the other should ask for input from the user so that a personalised postcard can be created. Display the postcard details as follows, "Dear " receiver, "Have a nice time at " place ; "Wish you a happy new year" "From " sender. 7. A string class contains two data members namely the length and a character pointer to a string. Use suitable overloaded constructor functions, Destructor and member functions to perform string operations. Also overload the following operators : + Concatenation == string comparison = String copy 8. Consider a class Date with members month, day, and year. Write suitable overloaded constructor functions, member functions to perform the date operations. You should also overload the following operators: ++ Increment date by 1 -- decrement date by 1 == compare two dates

***** END *****

Copyright Cognizant Academy All Rights Reserved

Vous aimerez peut-être aussi