Question: Q1. Open a text file and write the below record Read the file from your test driver to an array of accounts Zainul 1234567 97.67

Q1.

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

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:\\Users\\tchanlatif\\workspace\\week_13_I_O\\src\\tall.txt";

System.out.println(new File(".").getAbsoluteFile());

try

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

System.out.println("file exists");

while(scanner.hasNextLine())

{ String name = scanner.next();

int id=scanner.nextInt();

double balance = scanner.nextDouble();

}

}//

catch (Exception e){System.out.println(" *** No File-- ****");}

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!