Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

============================ import java.util.Scanner; import java.io.*; //This library is for reading and writing file /* IMPORTANT!!! This only serves as an example for your reference only.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

============================

import java.util.Scanner; import java.io.*; //This library is for reading and writing file

/* IMPORTANT!!! This only serves as an example for your reference only. This DOES NOT mean you will get full marks or anything close to an A grade by simply adopting this approach. In fact, there could be done in a smarter way. */ public class Lab1 {

public static String[] readFile(String fname){ //fname = "ast11103-acct.txt" int count = 0; //count how many records String[] acct = new String[10]; //acct storage for 10 try{ FileInputStream fis = new FileInputStream(fname); //Open the text file for reading Scanner sc = new Scanner(fis); //Begins to read the file while (sc.hasNextLine()){ //reading the file line by line acct[count] = sc.nextLine(); count++; } sc.close(); }catch(IOException e){ e.printStackTrace(); } return acct; } //Write data to a file public static void updateFile(String fname){ //refer https://www.digitalocean.com/community/tutorials/java-write-to-file for details } public static void main(String[] args) { // TODO code application logic here int size = 5; // No. of accounts String[] acct = new String[size]; //Store size (5) client's details //The .txt file must be put just 1 folder inside the project folder //The .txt file should be at the same level with folders like "build", "src", and "test", etc. acct = readFile("ast11103-acct.txt"); String[][] clientDetails = new String[size][4]; //Size (5) accts, and each a/c has 4 pieces of data // Print all records (1 record per line) for(int i = 0; i

=============================

You are asked to write a simple accounting programme that accurately records daily transactions of all account holders. The programme provides basic operations including: 1) opening an account, 2) closing an account, 3) deposit, 4) withdrawal, 5) reading accounts' details from a file, 6) writing account's details to the file, and 7) displaying account details, etc. Assuming the total number of clients will not exceed 100 (i.e. 100 accounts max.). The mentioned operations are executed by two types of users: manager and client. The programme itself should also automatically execute some operations. is section will define how the above operations should be performed. Programme - Reading accounts' details from a file - As the system start, the programme should prompt user (either in text or in GUI) to select a plain text file. - The plain text file contains lines of account record. Each line represents one record. To make it simple, each piece of data is separated by a comma containing name, account number, initial balance, and status (normal, closed, suspended). Following is an example: Li Yin Hong,123-4596-512,45955. 05,normal Yim Yik Wang,594-2844-213,12452. 50,normal Leung Judy, 149-5915-294,56866. 41, normal Pang Will,598-9244-234, 0, closed Chu Sing Yim,950-4814-234, 324.24, suspended - The programme should be able to read those data and break the record down into multiple pieces of data for further usage. - This operation can also be performed if the manager has manually requested. - Writing accounts' details to the file - Before closing the system, the programme should automatically write those modified account details back to the file so that all results of operations can be recorded. - This operation can also be performed if the manager has manually requested. - The file format should be maintained as mentioned in "Reading accounts' details from a file". Manager o Manual request to read/write accounts' details to the file o Refer the processes mentioned in the previous page "Programme" in Operation definition. o Opening an account - Input the name of client, assign an account number, and set initial balance. - Set status as "normal" by default. - Account number should be automatically given. The account number could not be duplicated to the existing ones. - Initial balance must be at least $100.00. - Make sure this new piece of account details will also be recorded to the file. o Closing an account - Input account number to retrieve existing record. If such a/c number does not exist, prompt a message to the manager. - If an account is found, prompt manager to reconfirm closure of account. - If reconfirmation is received, set account balance to 0 . - DON'T erase the account details. Simply change its status to "closed". - Be reminded such operation should be recorded to the file. - View account details - The programme should provide view(s) for the manager to understand the current records' details. - It would be helpful it the manger are permitted to have different views by applying some filters, for instance by account status. - Apply interests/charges - The manager can apply interests or charges to all or an individual account. - Interests and charges can be inputted as \% or actual amount. For example, the manager could give 5% interest to all accounts or apply $20 charges to an individual account. - End programme - Only the manager has the right to end the programme. Once this function has been triggered, results of account details should be recorded to the file. - Client - Deposit - Input (or select) a valid a/c number. If invalid, prompt user to re-enter. - Increase current balance by an inputted amount. - This operation is only possible if the account status is normal. - Withdrawal - Input (or select) a valid a/c number. If invalid, prompt user to re-enter. - Decrease current balance by an inputted amount. - The current balance must be bigger than the withdrawal amount. - This operation is only possible if the account status is normal. View of an individual account - View of his/her own account details: name, balance, and status Criteria - Error checking - You should be trying your best to make sure your programme not to be interfered by invalid input from users. If invalid inputs are found, prompt user for re-attempt. - Documentation - You programme should be given enough comments so that the marker could understand your work. - Programme flow - Programme flow should be user-friendly. Menus/pages should be carefully designed and "going back to previous manual" should be provided, if necessary. You are asked to write a simple accounting programme that accurately records daily transactions of all account holders. The programme provides basic operations including: 1) opening an account, 2) closing an account, 3) deposit, 4) withdrawal, 5) reading accounts' details from a file, 6) writing account's details to the file, and 7) displaying account details, etc. Assuming the total number of clients will not exceed 100 (i.e. 100 accounts max.). The mentioned operations are executed by two types of users: manager and client. The programme itself should also automatically execute some operations. is section will define how the above operations should be performed. Programme - Reading accounts' details from a file - As the system start, the programme should prompt user (either in text or in GUI) to select a plain text file. - The plain text file contains lines of account record. Each line represents one record. To make it simple, each piece of data is separated by a comma containing name, account number, initial balance, and status (normal, closed, suspended). Following is an example: Li Yin Hong,123-4596-512,45955. 05,normal Yim Yik Wang,594-2844-213,12452. 50,normal Leung Judy, 149-5915-294,56866. 41, normal Pang Will,598-9244-234, 0, closed Chu Sing Yim,950-4814-234, 324.24, suspended - The programme should be able to read those data and break the record down into multiple pieces of data for further usage. - This operation can also be performed if the manager has manually requested. - Writing accounts' details to the file - Before closing the system, the programme should automatically write those modified account details back to the file so that all results of operations can be recorded. - This operation can also be performed if the manager has manually requested. - The file format should be maintained as mentioned in "Reading accounts' details from a file". Manager o Manual request to read/write accounts' details to the file o Refer the processes mentioned in the previous page "Programme" in Operation definition. o Opening an account - Input the name of client, assign an account number, and set initial balance. - Set status as "normal" by default. - Account number should be automatically given. The account number could not be duplicated to the existing ones. - Initial balance must be at least $100.00. - Make sure this new piece of account details will also be recorded to the file. o Closing an account - Input account number to retrieve existing record. If such a/c number does not exist, prompt a message to the manager. - If an account is found, prompt manager to reconfirm closure of account. - If reconfirmation is received, set account balance to 0 . - DON'T erase the account details. Simply change its status to "closed". - Be reminded such operation should be recorded to the file. - View account details - The programme should provide view(s) for the manager to understand the current records' details. - It would be helpful it the manger are permitted to have different views by applying some filters, for instance by account status. - Apply interests/charges - The manager can apply interests or charges to all or an individual account. - Interests and charges can be inputted as \% or actual amount. For example, the manager could give 5% interest to all accounts or apply $20 charges to an individual account. - End programme - Only the manager has the right to end the programme. Once this function has been triggered, results of account details should be recorded to the file. - Client - Deposit - Input (or select) a valid a/c number. If invalid, prompt user to re-enter. - Increase current balance by an inputted amount. - This operation is only possible if the account status is normal. - Withdrawal - Input (or select) a valid a/c number. If invalid, prompt user to re-enter. - Decrease current balance by an inputted amount. - The current balance must be bigger than the withdrawal amount. - This operation is only possible if the account status is normal. View of an individual account - View of his/her own account details: name, balance, and status Criteria - Error checking - You should be trying your best to make sure your programme not to be interfered by invalid input from users. If invalid inputs are found, prompt user for re-attempt. - Documentation - You programme should be given enough comments so that the marker could understand your work. - Programme flow - Programme flow should be user-friendly. Menus/pages should be carefully designed and "going back to previous manual" should be provided, if necessary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Finance questions