Question: In this assignment, you will create a Java program to read bank accounts, including checking and savings accounts, from an input file, and write
In this assignment, you will create a Java program to read bank accounts, including checking and savings accounts, from an input file, and write them in reverse order to an output file. 1. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. For example, assume your package name is FuCIS265 and your main class name is FuAssignment4, and your executable files are in "C:\Users\2734848\eclipse-workspace CIS 265 Assignments\bin". The following command line will read from a local file "accounts.txt" and write to a local file "accounts_reversed.txt": C:\Users\2734848\eclipse-workspace CIS 265 Assignments \bin > java FUCIS265. FuAssignment4 accounts.txt accounts_reversed.txt You need to specify the command line arguments if you use an IDE such as jGrasp or Eclipes. The parameter String[] args in the main method contains the command line arguments, where args[0] contains the first argument. For example, in the previous command, args[0] contains accounts.txt, and args [1] contains accounts_reversed.txt. 4. If the program is run with incorrect number of arguments, your program must print an error message and exit. The error message must show correct format to run your program, e.g., "Usage: FUCIS265.FuAssignment4 input file output_file" where FuCIS265 is the package and FuAssignment4 is the main class. 2. 3. 5. Each line in the input file represents an account. There are 5 fields in each line: owner, number, balance, type (checking or savings), checkLimit or interest. The fields are separated by comma, ",". For example, th input file accounts.txt file may contain: James Bond, 200304, 1000. 33, checking, 20 Michelle Wang, 200224, 3333.3, savings, 0.5 Tayer Smith, 249843, 132.87, checking, 25 David Jess, 265334, 225.7, checking, 30 6. The program will read the lines and create checking or savings accounts accordingly. The accounts are stored in an ArrayList. 7. The program then writes the list of accounts in reserve order to the output file. 8. The program prints "Bye!" when it is done. 9. Given the previous input file accounts.txt, the output file, accounts reserved.txt, will be: David Jess, 265334, 225.7, checking, 30 Tayer Smith, 249843, 132.87, checking, 25 Michelle Wang, 200224, 3333.3, savings, 0.5 James Bond, 200304, 1000. 33, checking, 20 II. Implementation Requirements The program must implement a main class and three bank account classes (BankAccount, CheckingAccount, Savings Acount) which are specified in the following UML class diagram. The changes from previous assignments are shown in red. -owner: String -number: int BankAccount -balance: double +Bank Account() +Bank Account(String, int, double) +printBank Account():void +getNumber(): int +printBank Account(Print Writer pw):void CheckingAccount Savings Account -interest: double + Savings Account () + Savings Account (String, int, double, double) +printBankAccount():void -checkLimit: int +Checking Account() +Checking Account (String, int, double, int) +printBankAccount():void +printBankAccount(PrintWriter pw):void +printBank Account(Print Writer pw):void All classes must be in the same package. The package name must start with your last name. For example, if your last name is "Biden", your package name must start with "Biden" such as "BidenCIS265", "BidenData Structures", etc. You main class file name must start with your last name. For example, if your last name is "Spiderman", your main class file name must start with "Spiderman" such as "Spiderman4.java", "SpidermanAssign4.java", etc. The Bank Account class must be abstract and have a no-arg constructor, and a constructor with 3 parameters: a String, an int, and a double. It must have a method printBank Account() to print its owner, number, and balance. It must have a method getNumber() which returns its number. It also must have a method printBankAccount(Print Writer pw) that writes the account's owner, number, and balance to the file. The Checking Account class must extends the BankAccount class. It must have a no-arg constructor and a constructor with 4 parameters: a String, an int, a double, and an int. The constructor with parameters must call the Bank Account's constructor. It must also override the printBankAccount() method to print its owner, number, balance, and checkLimit. It must also override the printBank Account(Print Writer pw) method to write its owner, number, balance, and checkLimit to the file. The Savings Account class must extends the Bank Account class. It must have a no-arg constructor and a constructor with 4 parameters: a String, an int, a double, and a double. The constructor with parameters must call the BankAccount's constructor. It must also override the printBankAccount() method to print its owner, number, balance, and interest. It must also override the printBankAccount(Print Writer pw) method to write its owner, number, balance, and interest to the file. Since I/O exceptions are checked exceptions, your main class must handle exceptions. You may use the try/catch or throw IOException. To throw exceptions, you declare it as: public static void main(String[] args) throws IOException You may reuse the code from previous assignments. However, please not the changes to the bank account classes. Your program must close both input and output files after they are done, unless they are put in the try-with- resource block. You can assume that input file has the correct format. You will earn bonus points for handling incorrect input formats. III. Submission This is an individual assignment. Each student needs to submit the source code files of the Java program on Blackboard. In this assignment, you will create a Java program to read bank accounts, including checking and savings accounts, from an input file, and write them in reverse order to an output file. 1. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. For example, assume your package name is FuCIS265 and your main class name is FuAssignment4, and your executable files are in "C:\Users\2734848\eclipse-workspace CIS 265 Assignments\bin". The following command line will read from a local file "accounts.txt" and write to a local file "accounts_reversed.txt": C:\Users\2734848\eclipse-workspace CIS 265 Assignments \bin > java FUCIS265. FuAssignment4 accounts.txt accounts_reversed.txt You need to specify the command line arguments if you use an IDE such as jGrasp or Eclipes. The parameter String[] args in the main method contains the command line arguments, where args[0] contains the first argument. For example, in the previous command, args[0] contains accounts.txt, and args[1] contains accounts_reversed.txt. 4. If the program is run with incorrect number of arguments, your program must print an error message and exit. The error message must show correct format to run your program, e.g., "Usage: FUCIS265.FuAssignment4 input file output_file" where FuCIS265 is the package and FuAssignment4 is the main class. 2. 3. 5. Each line in the input file represents an account. There are 5 fields in each line: owner, number, balance, type (checking or savings), checkLimit or interest. The fields are separated by comma, ",". For example, th input file accounts.txt file may contain: James Bond, 200304, 1000. 33, checking, 20 Michelle Wang, 200224, 3333.3, savings, 0.5 Tayer Smith, 249843, 132.87, checking, 25 David Jess, 265334, 225.7, checking, 30 6. The program will read the lines and create checking or savings accounts accordingly. The accounts are stored in an ArrayList. 7. The program then writes the list of accounts in reserve order to the output file. 8. The program prints "Bye!" when it is done. 9. Given the previous input file accounts.txt, the output file, accounts reserved.txt, will be: David Jess, 265334, 225.7, checking, 30 Tayer Smith, 249843, 132.87, checking, 25 Michelle Wang, 200224, 3333.3, savings, 0.5 James Bond, 200304, 1000. 33, checking, 20 II. Implementation Requirements The program must implement a main class and three bank account classes (BankAccount, CheckingAccount, Savings Acount) which are specified in the following UML class diagram. The changes from previous assignments are shown in red. -owner: String -number: int BankAccount -balance: double +Bank Account() +Bank Account(String, int, double) +printBank Account():void +getNumber(): int +printBank Account(PrintWriter pw):void CheckingAccount -checkLimit: int +Checking Account() +Checking Account (String, int, double, int) +printBankAccount():void +printBankAccount(Print Writer pw):void Savings Account -interest: double + Savings Account () + Savings Account (String, int, double, double) +printBankAccount():void +printBank Account(Print Writer pw):void All classes must be in the same package. The package name must start with your last name. For example, if your last name is "Biden", your package name must start with "Biden" such as "BidenCIS265", "BidenData Structures", etc. You main class file name must start with your last name. For example, if your last name is "Spiderman", your main class file name must start with "Spiderman" such as "Spiderman4.java", "SpidermanAssign4.java", etc. The Bank Account class must be abstract and have a no-arg constructor, and a constructor with 3 parameters: a String, an int, and a double. It must have a method printBank Account() to print its owner, number, and balance. It must have a method getNumber() which returns its number. It also must have a method printBankAccount(Print Writer pw) that writes the account's owner, number, and balance to the file. The Checking Account class must extends the BankAccount class. It must have a no-arg constructor and a constructor with 4 parameters: a String, an int, a double, and an int. The constructor with parameters must call the Bank Account's constructor. It must also override the printBankAccount() method to print its owner, number, balance, and checkLimit. It must also override the printBank Account(Print Writer pw) method to write its owner, number, balance, and checkLimit to the file. The Savings Account class must extends the Bank Account class. It must have a no-arg constructor and a constructor with 4 parameters: a String, an int, a double, and a double. The constructor with parameters must call the BankAccount's constructor. It must also override the printBankAccount() method to print its owner, number, balance, and interest. It must also override the printBankAccount(Print Writer pw) method to write its owner, number, balance, and interest to the file. Since I/O exceptions are checked exceptions, your main class must handle exceptions. You may use the try/catch or throw IOException. To throw exceptions, you declare it as: public static void main(String[] args) throws IOException You may reuse the code from previous assignments. However, please not the changes to the bank account classes. Your program must close both input and output files after they are done, unless they are put in the try-with- resource block. You can assume that input file has the correct format. You will earn bonus points for handling incorrect input formats. III. Submission This is an individual assignment. Each student needs to submit the source code files of the Java program on Blackboard. In this assignment, you will create a Java program to read bank accounts, including checking and savings accounts, from an input file, and write them in reverse order to an output file. 1. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. For example, assume your package name is FuCIS265 and your main class name is FuAssignment4, and your executable files are in "C:\Users\2734848\eclipse-workspace CIS 265 Assignments\bin". The following command line will read from a local file "accounts.txt" and write to a local file "accounts_reversed.txt": C:\Users\2734848\eclipse-workspace CIS 265 Assignments \bin > java FUCIS265. FuAssignment4 accounts.txt accounts_reversed.txt You need to specify the command line arguments if you use an IDE such as jGrasp or Eclipes. The parameter String[] args in the main method contains the command line arguments, where args[0] contains the first argument. For example, in the previous command, args[0] contains accounts.txt, and args [1] contains accounts_reversed.txt. 4. If the program is run with incorrect number of arguments, your program must print an error message and exit. The error message must show correct format to run your program, e.g., "Usage: FUCIS265.FuAssignment4 input file output_file" where FuCIS265 is the package and FuAssignment4 is the main class. 2. 3. 5. Each line in the input file represents an account. There are 5 fields in each line: owner, number, balance, type (checking or savings), checkLimit or interest. The fields are separated by comma, ",". For example, th input file accounts.txt file may contain: James Bond, 200304, 1000. 33, checking, 20 Michelle Wang, 200224, 3333.3, savings, 0.5 Tayer Smith, 249843, 132.87, checking, 25 David Jess, 265334, 225.7, checking, 30 6. The program will read the lines and create checking or savings accounts accordingly. The accounts are stored in an ArrayList. 7. The program then writes the list of accounts in reserve order to the output file. 8. The program prints "Bye!" when it is done. 9. Given the previous input file accounts.txt, the output file, accounts reserved.txt, will be: David Jess, 265334, 225.7, checking, 30 Tayer Smith, 249843, 132.87, checking, 25 Michelle Wang, 200224, 3333.3, savings, 0.5 James Bond, 200304, 1000. 33, checking, 20 II. Implementation Requirements The program must implement a main class and three bank account classes (BankAccount, CheckingAccount, Savings Acount) which are specified in the following UML class diagram. The changes from previous assignments are shown in red. -owner: String -number: int BankAccount -balance: double +Bank Account() +Bank Account(String, int, double) +printBank Account():void +getNumber(): int +printBank Account(PrintWriter pw):void CheckingAccount Savings Account -interest: double + Savings Account () + Savings Account (String, int, double, double) +printBankAccount():void -checkLimit: int +Checking Account() +Checking Account (String, int, double, int) +printBankAccount():void +printBankAccount(PrintWriter pw):void +printBank Account(Print Writer pw):void All classes must be in the same package. The package name must start with your last name. For example, if your last name is "Biden", your package name must start with "Biden" such as "BidenCIS265", "BidenData Structures", etc. You main class file name must start with your last name. For example, if your last name is "Spiderman", your main class file name must start with "Spiderman" such as "Spiderman4.java", "SpidermanAssign4.java", etc. The Bank Account class must be abstract and have a no-arg constructor, and a constructor with 3 parameters: a String, an int, and a double. It must have a method printBank Account() to print its owner, number, and balance. It must have a method getNumber() which returns its number. It also must have a method printBankAccount(Print Writer pw) that writes the account's owner, number, and balance to the file. The Checking Account class must extends the BankAccount class. It must have a no-arg constructor and a constructor with 4 parameters: a String, an int, a double, and an int. The constructor with parameters must call the Bank Account's constructor. It must also override the printBankAccount() method to print its owner, number, balance, and checkLimit. It must also override the printBank Account(Print Writer pw) method to write its owner, number, balance, and checkLimit to the file. The Savings Account class must extends the Bank Account class. It must have a no-arg constructor and a constructor with 4 parameters: a String, an int, a double, and a double. The constructor with parameters must call the BankAccount's constructor. It must also override the printBankAccount() method to print its owner, number, balance, and interest. It must also override the printBankAccount(Print Writer pw) method to write its owner, number, balance, and interest to the file. Since I/O exceptions are checked exceptions, your main class must handle exceptions. You may use the try/catch or throw IOException. To throw exceptions, you declare it as: public static void main(String[] args) throws IOException You may reuse the code from previous assignments. However, please not the changes to the bank account classes. Your program must close both input and output files after they are done, unless they are put in the try-with- resource block. You can assume that input file has the correct format. You will earn bonus points for handling incorrect input formats. III. Submission This is an individual assignment. Each student needs to submit the source code files of the Java program on Blackboard.
Step by Step Solution
There are 3 Steps involved in it
Solution A complete Java program that reads bank accounts from an input file stores them in an ArrayList and then writes them in reverse order to an output file import javaio import javautil BankAccou... View full answer
Get step-by-step solutions from verified subject matter experts
