Page 560 - Cs_withBlue_J_C11_Flipbook
P. 560

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 : ");



                558558  Touchpad Computer Science-XI
   555   556   557   558   559   560   561   562   563   564   565