Menu

Q1 Open Text File Write Record Read File Test Driver Array Accounts Zainul 1234567 9767 Zo Q43790324

Q1.

  1. Open a text file and write the below record
  2. Read the file from your test driver to an array ofaccounts

Zainul    1234567           97.67

Zoubi      978678            278.40

Shawa     8912345          356.78

                  Ussama  98765             167.00

                   Islam     1123               298.8

                   Abeer    98767             300.0

                   Maryam  987656           299.0

      String fileName =”C:Userstchanlatifworkspaceweek_13_I_Osrctall.txt”;

            System.out.println(newFile(“.”).getAbsoluteFile());

            try

            {      Scanner scanner =new Scanner(newFile(fileName));

                  System.out.println(“file exists”);

                   while(scanner.hasNextLine())

                   {   String name = scanner.next();

                       int id=scanner.nextInt();

                       double balance =scanner.nextDouble();

                   }                  

               }//

         catch (Exceptione){System.out.println(” ***  No File– ****”);}

  1. Write a function that accepts all the accounts and also theaccount_ID. The function should return thebankaccount whose id is account_ID. If does notfind such account tt should throw an exception

Expert Answer


Answer to Q1. Open a text file and write the below record Read the file from your test driver to an array of accounts Zainul 12345…

OR