Sunday 21 August 2016

CLASS - XII ASSIGNMENT-2 ON DATA FILE HANDLING



CLASS-XII

PROGRAM ON BINARY FILE


     1.      Given a binary file STUDENT.DAT, containing records of the following class Student type
class Student
{
            char S_Admno[lO];    //Admission number of student
            char S_Name[30];       //Name of student
            int Percentage;            //Marks Percentage of student
            public:
                        void EnterData();
                        void DisplayData();
                        int get_Percentage();
};
Write a program in C++, that would read contents of file STUDENT.DAT and display the details of those Students whose Percentage is above 75.

      2.      Assuming the class Computer as follows :
class computer
{
            char chiptype[10];
            int speed;
            public:
                        void getdetails();
                        void showdetails();
};
Write a function readfile( ) to read all the records present in an already existing binary file SHIP.DAT and display them on the screen, also count the number of records present in the file.

      3.      Consider the given class

class student
{
            int admno;
            char name[20];
public:
          void getdata();
          void showdata();
          int retadmno();
};

Write a menu driven program for the following:

1.     Add new records
2.     Display records
3.     Search and display record
4.     Delete the record
5.     Modify the record

4.      Write a menu driven program in C++ to perform the following functions on a binary file “BOOK.DAT” containing objects of the following class:
class Book
{           int BookNo;
            char Book_name[20];
  public:
            void enterdetails();
            void showdetails();
            int Rbook_no() {return Book_no;}
            int Rbook_name() {return Book_name;}

};
a)      Append Records
b)      Modify a record for a given book no.
c)      Delete a record with a given book no.
d)      Search for a record with a given Book name
e)      Display a sorted list of records (sort on Book No.)
            f)       Display a sorted list of records (Sort on Book Name)

5.      A blood bank maintains a data file that contains the following information for every donor: Name, Date of Birth, Telephone number, Blood group. Write a program in C++ to do the following:
a) Given a blood group, display name, date of birth and phone number of all the persons of the given    
   blood group.
b) Append records in the file.
c)  Input a telephone number and modify the corresponding record.

6.      Declare a structure telerec in C++, containing name (20 characters) and telephone number. Write a program to maintain a file of telephone records. The program should allow the following functions on the file:
a)      To append records in the file.
b)      Display the name for a given telephone number. If the telephone number does not exist then display error message "record not found".
            c)      Display the telephone number(s) for a given name. If the name does not exist then display error message "record not found".

      7.      Assuming the class TOYS as declared below and write a program in C++ to read the objects of TOYS from binary file TOYS.DAT and display details of those TOYS, which are meant for children of AgeRange "5 to 8".                                                                                                          
class TOYS
    {
            int ToyCode;
            char ToyName[10];
            char AgeRange;
            public:
            void Enter()
            void Display()
                        char* WhatAge()
 };
       8.      Write a program in C++ to search for a camera from a binary file “CAMERA.DAT” containing the objects of class CAMERA (as defined below). The user should enter the Model No and the function should search and display the details of the CAMERA.                                 
 class CAMERA                                            
 {
            long ModelNo;
            float MegaPixel;
            int Zoom;
            char Details[120];
            public:
            void Enter();
            void Display();
            long GetModelNo();

};

No comments:

Post a Comment