懂英文的,求指点或帮助,作业
http://115.com/file/c228wdkz#BankSystem.pdfhttp://115.com/file/易做图b44o8#data.txt --------------------编程问答-------------------- 你要问的是什么 ? --------------------编程问答-------------------- ArrayList 不懂, 还有怎样读取data.txt的内容 --------------------编程问答--------------------
import java.io.*;--------------------编程问答-------------------- 看了, 题目有点深... --------------------编程问答-------------------- 看了, 题目有点深... --------------------编程问答-------------------- ArrayList 是一种特殊的数据结构,底层封装了数组,里面的每一个元素都有一个固定的坐标(index),可以使用list.add(XX)加入一个元素,也可用list.get(index)去取得里面的元素 --------------------编程问答-------------------- 随便看看谁人可完成
import java.util.*;
public class RetailBankSystem {
private static ArrayList<String> lines = new ArrayList<String>();
//private static ArrayList<Account> accts = new ArrayList<Account>();
private static int date = 25; // Default the transaction as 25 May 2012
public static void main(String[] args) {
try {
// Application start
System.out.println();
System.out.println("Retail Account System");
System.out.println("=============================");
System.out.println("Date: " + date + " May 2012");
System.out.println();
// Loading data from text file
loadData();
}
catch (Exception ex) {
System.out.println("**** ERROR: " + ex.getMessage() + " ****");
System.exit(1);
}
//...........
}
// Loading the data
public static void loadData() throws Exception {
File inFile = new File("data.txt");
Scanner freader = new Scanner(inFile);
String line = null;
int acct_cnt = 0;
int tran_cnt = 0;
int invalid_cnt = 0;
while (freader.hasNextLine()) {
line = freader.nextLine();
lines.add(line);
if(line.startsWith("PAC")||line.startsWith("SAV")||line.startsWith("CUR")){
acct_cnt++;
}else{
invalid_cnt++;
}
}
freader.close();
System.out.println("Data loaded");
System.out.println("----------------------------------------");
System.out.println("No of Account: " + acct_cnt);
System.out.println("No of Transaction: " + tran_cnt);
System.out.println("No of Invalid Data: " + invalid_cnt);
System.out.println("----------------------------------------");
}
}
补充:Java , Java SE