class xii cscince practical assignment

17
Class XII Computer Science(083) Practical Assignments Cscience_1 : Write a Program in C++ to add two distance type objects into third one. Structure distance contains following components- 1. feet (integer type) 2. inches (integer type) (Program must have following general functions- 1. To input a distance type object. 2.To add two distance type objects (Pass two distance type arguments and return a distance type object). 3. To display distance type object.) Cscience_2 : Imagine a ticket selling booth at a fair. People passing by are requested to purchase a ticket. A ticket is priced Rs. 2.50/- The booth keeps the track of the number of people that have visited the booth, and of the total amount of money collected. Model this ticket selling booth with a class ticbooth including following members : Data Members : Number of people visited. Total amount of money collected. Member Functions : To assign initial values (assign 0 to both data members) To increment only people total in case ticket is not sold out. Class XII, Computer Science(083) ,Practical Assignments, Page :#1

Upload: dheeraj-vijay

Post on 01-Dec-2015

183 views

Category:

Documents


0 download

DESCRIPTION

Assignment for School students of 12th class of any school.

TRANSCRIPT

Page 1: Class XII Cscince Practical Assignment

Class XIIComputer Science(083)Practical Assignments

Cscience_1 : Write a Program in C++ to add two distance type objects into third one. Structure distance contains following components-

1. feet (integer type)2. inches (integer type)

(Program must have following general functions-1. To input a distance type object.2. To add two distance type objects (Pass two distance type arguments

and return a distance type object).3. To display distance type object.)

Cscience_2 : Imagine a ticket selling booth at a fair. People passing by are requested to purchase a ticket. A ticket is priced Rs. 2.50/- The booth keeps the track of the number of people that have visited the booth, and of the total amount of money collected.Model this ticket selling booth with a class ticbooth including following members :Data Members : Number of people visited.Total amount of money collected.Member Functions :To assign initial values (assign 0 to both data members)To increment only people total in case ticket is not sold out.To increment people total as well as amount total if a ticket is sold outTo display the two totalsTo display the number of tickets sold out ( a tricky one)

Test above-mentioned class in main() function.

Cscience_3 : Define a class to represent batsmen in a cricket team. Include the following members:Data members :First name Last name Runs madeNumber of fours

Class XII, Computer Science(083) ,Practical Assignments, Page :#1

Page 2: Class XII Cscince Practical Assignment

Number of sixesMember Functions :To assign the initial valuesTo update runs made(It should simultaneously update fours and sixes, if required)To display the batsman’s information.

Test this class in main() function. Make 11 objects to represent a team.Make a menu with following options.

1. Assign the basic values to all of the team members.2. Update the information of any batsman on the basis of his first name3. Display the information of any batsman on the basis of his first name4. Quit

Cscience_4 : Write a program in C++ with the help of following class student –Data Members :Name of the studentMarks in five subject (An array of float)Total marks obtainedPercentageNo. of pass students (static)No. of fail students ( static)No. of first divisions (static)No. of second divisions (static)No. of third division (static)

Member Functions.1. To input detail of a student (Name and marks in five subjects)2. To display detail of a student3. To calculate the total marks, percentage and static member data.

Declare this member function as private and call it from input detail function.

4. To display static data members’ detail (A static member function) .Test this class for 10 students. (An array of student type)

(Note: If marks scored by student in every subject is>=33 , student is pass and division must be calculated as follows –Percentage Division>=60 I

Class XII, Computer Science(083) ,Practical Assignments, Page :#2

Page 3: Class XII Cscince Practical Assignment

>=50 and <60 II>=33 and <50 III

Otherwise student is fail and division is supposed to be NIL.)

Cscience_5 : Write a menu-driven program in C++ to calculate the volume of following shapes-

1. Volume of a cube2. Volume of a box 3. Volume of a sphere.4. Quit

Make this program with the help of a class shape with following-Member data:p1 (type float)p2 (type float)p3 (type float)volume (type float)

Member Functions :To input data members (Input as many as required)To calculate volume of various shapes (must be overloaded)To display the volume.

Cscience_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) and 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().

Test classes book and tape from main function. Implement the concept of member function over-riding.

Class XII, Computer Science(083) ,Practical Assignments, Page :#3

Page 4: Class XII Cscince Practical Assignment

Cscience_7 : Write a menu-driven program in C++ with following options-1. Creation of a text file (file must be created, character by character

until a particular character is typed , like as you type ‘#’ the file creation task gets stopped)

2. Reading of a created text file. (To display the contents of a text file)3. Quit.

Cscience_8 : Write a menu-driven program in C++ with following options-1. Creation of a text file (say file is mixed.txt, it contains alphabets,

digits or special characters)2. Make separate files (This option creates three files- alpha.txt (contains

alphabets only), digit.txt (contains digits only) and special.txt (contains special characters only) taking data from mixed.txt)

3. Display a file (This option displays the contents of a particular file out of above-mentioned four files, by asking its name, if not found reports “file not found”)

4. Quit

Cscience_9 : Write a menu-driven program in C++ with following options-1. To add records (Name, Rollno, Marks ) of students (Add records till

the user wants ‘yes’)2. Display all the records3. Display a particular record on the basis of Roll No.4. Quit

Cscience_10 : Write a program in C++ with the help of following class employee –Member Data : Employee nameEmployee codeBasic SalaryDaHraTotal salary

Member Functions:1. To input employee detail (name, code and basic)2. To calculate following

Class XII, Computer Science(083) ,Practical Assignments, Page :#4

Page 5: Class XII Cscince Practical Assignment

Code Da Hra1 50% of basic 30% of basic2 40% of basic 25% of basicAny other 30% of basic 20% of basic

Total Salary=Basic + Da + HraThis function must be a private function and must be called from input detail function3. A function which returns the address of that object which has got higher basic salary(This function compares calling object and passing object)4. To display the detail of the student In main() function make 10 objects of employee. Input and calculate detail of every employee .Finally display the detail of that employee who draws the highest salary.

Cscience_11: Write a program in C++ with the help of class array_search with following members-Member data :An array ar of integer with 100 elementsNo .of elements actually used by user (int n)

Member Functions-1. To input n, and n number of elements2. Linear serch3. Binary search (If array is in ascending order)4. To display n elements of the array

Make a menu in C++ with following options-1. Array Input 2. Linear Search3. Binary Search4. Array display 6. Quit

Cscience_12: Write a program in C++ with the help of class array_update with following members-Member data :An array ar of integer with 100 elementsNo .of elements actually used by user (int n)

Class XII, Computer Science(083) ,Practical Assignments, Page :#5

Page 6: Class XII Cscince Practical Assignment

Member Functions-1. To input n, and n number of elements2. To insert an item in the array if array is in ascending order4. To delete an item from the array5. To display n elements of the array

Make a menu in C++ with following options-1. Array Input 2. Insertion3. Deletion4. Array display 6. Quit

Cscience_13: Write a program in C++ with the help of class array_sort with following members-Member data :An array ar of integer with 100 elementsNo .of elements actually used by user (int n)

Member Functions-1. To input n, and n number of elements2. Selection sort3. Bubble sort4. Insertion sort5. To display n elements of the array

Make a menu in C++ with following options- 1. Array Input

2. Selection sort3. Bubble sort4. Insertion sort5. Array display 6. Quit

Cscience_14: Write a program in C++ with the help of class array_merge with following members-Member data :An array a of integer with 100 elementsNo .of elements actually used by user in array a (int l)An array b of integer with 100 elementsNo .of elements actually used by user in array b (int m)

Class XII, Computer Science(083) ,Practical Assignments, Page :#6

Page 7: Class XII Cscince Practical Assignment

An array c of integer with 200 elementsNo .of elements actually used by user in array c (int n)

Member Functions-1. To input array a and b with size l, m respectively2. merge1(), it merges array a and b to form c, if a and b are

sorted in ascending and descending order respectively3. merge2(), it merges array a and b to form c, if a and b are sorted in

descending and ascending order respectively4. merge3(), it merges array a and b to form c, if a and b are sorted

in ascending order5. merge4(), it merges array a and b to form c, if a and b are sorted

in descending order (Note :Array c is required in ascending order.)

6. display(), To display all the arrays a, b and c.

Make a menu in C++ with following options-1. To input array a, b 2. To merge array a and b to form c, if a and b are sorted in

ascending and descending order respectively3. To merge array a and b to form c, if a and b are sorted in

descending and ascending order respectively4. To merge array a and b to form c, if a and b are sorted in

ascending order 5. To merge array a and b to form c, if a and b are sorted in

descending order 6. To display all the arrays.7. Quit

Cscience_15: Write a program in C++ with the help of class linked_list with following members-(Nodes of the linked list are created by self-referential structure node-struct node{

int info;node *next;

}; )

Member data :Class XII, Computer Science(083) ,Practical Assignments,

Page :#7

Page 8: Class XII Cscince Practical Assignment

A pointer start which keeps the address of first node.Member Functions-

1. A constructor which keeps NULL in start.2. To add a node in a linked list3. For traversal (Display info. of each node)4. To search a particular node, on the basis of information of

nodes given.Make a menu in C++ with following options-

1. To create a linked list.2. For linked list traversal.3. To search a particular node4. Quit.

Cscience_16: Write a program in C++ with the help of class array_stack with following members-

Member data :An array of integer ar[MAX](Where MAX is a globally-declared symbolic-constant (integer) with size according to the requirement of user) top (It keeps the index of top most array element)Member Functions-

1. A constructor that initialize –1 in top (Makes array_stack ready to push)

2. To push an item in stack.3. To pop an item from stack4. To display the content of stack without popping

Make a menu in C++ with following options-1. A initialize the stack( top must be -1)2. To push an item in stack.3. To pop an item from stack4. To display the content of stack without popping5. Quit

Cscience_17: Write a program in C++ with the help of class linked_stack with following members-(Nodes of the linked stack are created by self-referential structure node-

Class XII, Computer Science(083) ,Practical Assignments, Page :#8

Page 9: Class XII Cscince Practical Assignment

struct node{

int info;node *next;

}; )

Member data :A pointer top which keeps the address of top-most node.Member Functions-

1.A constructor that initialize NULL in top (Makes array_stack ready to push)2. To push an item on stack.3. To pop an item from stack4. To display the content of stack without popping

Make a menu in C++ with following options-1. A initialize the stack( top must be NULL)2. To push an item in stack.3. To pop an item from stack4. To display the content of stack without popping5. Quit

Cscience_18: Write a program in C++ with the help of class array_queue with following members-

Member data :An array of integer ar[MAX](Where MAX is a globally-declared symbolic-constant (integer) with size according to the requirement of user) front and rear ( They keep the index of front-most and rear-most array element)Member Functions-

1. A constructor that initialize –1 in front and rear (Makes array_queue ready for insertion)2. To insert an item in queue.3. To delete an item from queue4. To display the content of queue without deletion.

Make a menu in C++ with following options-

Class XII, Computer Science(083) ,Practical Assignments, Page :#9

Page 10: Class XII Cscince Practical Assignment

1. To initialize the queue( front and rear must be -1)2. To insert an item in queue3. To delete an item from queue4. To display the contents of queue without deletion5. Quit

Cscience_19: Write a program in C++ with the help of class linked_queue with following members- (Nodes of the linked queue are created by self-referential structure node-struct node{

int info;node *next;

}; )

member Data :front and rear ( They keep the memory address of front-most and rear-most linked queue)Member Functions-

1. A constructor that initialize NULL in front and rear (Makes linked__queue ready for insertion)2. To insert an item in queue.3. To delete an item from queue4. To display the content of queue without deletion.

Make a menu in C++ with following options-1. To initialize the queue( front and rear must be NULL)2. To insert an item in queue3. To delete an item from queue4. To display the contents of queue without deletion5. Quit

Cscience_20: Write a program in C++ with the help of class circular_array_queue with following members-

Member data :An array of integer ar[MAX](Where MAX is a globally-declared symbolic-constant (integer) with size according to the requirement of user)

Class XII, Computer Science(083) ,Practical Assignments, Page :#10

Page 11: Class XII Cscince Practical Assignment

front and rear ( They keep the index of front-most and rear-most array element)Member Functions-

1. A constructor that initialize –1 in front and rear (Makes circular_array_queue ready for insertion)2. To insert an item in circular queue.3. To delete an item from circular queue4. To display the content of circular queue without deletion.

Make a menu in C++ with following options-1. To initialize the queue( front and rear must be -1)2. To insert an item in queue3. To delete an item from queue4. To display the contents of queue without deletion5. Quit

Cscience_21: On the basis of following table supplier.

Table : SUPPLIER

Numbers Name City Itemno SuppliedQty RateS001 Puneet Delhi 1008 100 40S002 Pradeep Bangalore 1009 200 30S003 Tanmay Delhi 1008 150 40S004 Rohini Bombay 1005 190 20S005 Tanya Bombay 1003 20 50S006 Aditi Madras 1008 180 40S007 Kush Delhi 1009 300 30

Write SQL commands for (b) to (g) and write the outputs of SQL commands given in (h) with the help of above shown table.

(b)Display names of suppliers whose names start with the letter ‘T’.(c) Display details of suppliers residing in Delhi.(d)Display supplier name, item numbers, and supplied quantity for quantity

> 150.(e) Create a view with one of the columns as rate * 10.(f) List the suppliers name in the descending order of supplied quantity.(g)List the different cities contained in supplier table.

Class XII, Computer Science(083) ,Practical Assignments, Page :#11

Page 12: Class XII Cscince Practical Assignment

(h)Give the output of the following SQL commands on the basis of table supplier.

(i) SELECT MIN(Rate) FROM SUPPLIER(ii) SELECT COUNT(DISTINCT City) FROM SUPPLIER(iii) SELECT Name, Itemno FROM SUPPLIER WHERE

SuppliedQty>150(iv) SELECT (Rate*SuppliedQty) FROM SUPPLIER WHERE SuppliedQty>200

NOTE :Similarly four more assignments Cscience_22, Cscience_23, Cscience_24, and Cscience_25 can be taken up by students on their own for SQL.

Class XII, Computer Science(083) ,Practical Assignments, Page :#12