Page 553 - ComputerScience_Class_11
P. 553

Project  2    Write a program using binary file concept to create a binary file "info.dat”.
                                 1.   The file stores the name, PAN number and total tax Income for various people till the user
                                    wants and updates the above file by appending new data till the user wishes.
                                 2.   Update the binary file “info.dat” by deleting those records where taxable income is less
                                    than or equal to 100000.
                                 3.   Now, modify the above binary file by converting all the names into uppercase.
                                 4.   Read the above binary file “info.dat” to print all the records after updating the file.

                   1       import java.io.*;
                   2       class Binary_File
                   3       {
                   4           public static void main(String args[])throws IOException
                   5           {
                   6               InputStreamReader ISR = new InputStreamReader(System.in);
                   7               BufferedReader br = new BufferedReader(ISR);
                   8               String name,pan,choice;
                   9               int ch;

                   10              double taxIncome;
                   11              do
                   12              {
                   13                  System.out.println("Main Menu");
                   14                  System.out.println("Press 1 for creating a file");
                   15                  System.out.println("Press 2 for appending a file");
                   16                  System.out.println("Press 3 for deleting data from a file");

                   17                  System.out.println("Press 4 for modifying a file");
                   18                  System.out.println("Press 5 for reading a file");
                   19                  System.out.println("Press 6 to exit");
                   20                  System.out.print("Please enter your choice : ");
                   21                  ch = Integer.parseInt(br.readLine());
                   22                  switch(ch)
                   23                  {
                   24                      case 1:

                   25                           DataOutputStream mat=new DataOutputStream(new FileOutputStream

                                                 ("info.dat"));
                   26                          do
                   27                          {
                   28                              System.out.print("Input Name of Employee : ");
                   29                              name =  br.readLine();

                   30                              System.out.print("Input Pan Number : ");
                   31                              pan = br.readLine();
                   32                              System.out.print("Input TaxableIncome : ");





                                                                                                   Sample Projects  551
   548   549   550   551   552   553   554   555   556   557   558