I have to create a program which reads and processes an input file with account transactions ordered by transaction date
and generates a report every time the date of the current transaction being processed is different than the last processed transaction
This is what I have so far
//importing packages needed to create class import java.util.*; import java.io.*; //creating class account which will include constructors, accessors and mutator methods public class Account { //initializing variables private static int accountId; private static double balance; //default constructor public Account() { accountId = 0; balance = 0.0; } //constructor which will take in parameters public Account(int accountId, double balance) { this.accountId = accountId; this.balance = balance; } //mutator method which will change variable accountId public void setId(int id) { accountId = id; } //accessor method which will return the value stored in Accountid public int getAccountId() { return accountId; } //mutator method which will change variable balance public void setBalance(double balance) { this.balance = balance; } //accesor method which will return the value stored in balance public double getBalance() { return balance; } }
my main class
What i dont know how to do is add those elements from the input file and place them in my vector?//Mario Gutierrez, CS_2401, MWF 8:30 a.m. //importing packages needed to create class import java.util.*; import java.io.*; /*this program will read and process an input file and generates a report every time **the date of the current transaction changes */ public class BankAccount { private static char action; private static int acctId; private static long date; private static double bal; private static int count; //creating main method where report will be generated public static void main(String[] args)throws FileNotFoundException { //creating scanner which will read input file Scanner input = new Scanner(new FileReader("input.txt")); input.useDelimiter(",\\s*"); //initializing variables Vector<String> bank = new Vector<String>(); while(input.hasNext()) { date = input.nextLong(); acctId = input.nextInt(); action = input.next().charAt(0); bal = input.nextDouble(); System.out.print(date); System.out.print(" "); System.out.print(acctId); System.out.print(" "); System.out.print(action); System.out.print(" "); System.out.print(bal); System.out.println(); } System.out.print(bank); input.close(); } }
can anyone help me to finish this program thank you