📄 chinamobileexpensestatistics.java
字号:
import java.io.*;
import java.util.*;
public class ChinaMobileExpenseStatistics
{
FileReader file;
Vector all = new Vector();
long 虚拟网呼入时间 = 0;
long 虚拟网呼出时间 = 0;
long 网内短信条数 = 0;
long 网外短信条数 = 0;
long 本地呼出时间 = 0;
long 本地呼入时间 = 0;
private String getValue()
{
int c;
StringBuffer temp = new StringBuffer();
try{
while((c = file.read())!=(int)(' '))
{
temp.append((char)c);
}
}catch(IOException e){
System.out.println("IOexception in getvalue()");
}
return new String(temp);
}
private void compute()
{
for(int i=0;i<all.size();i++)
{
Record r = (Record)all.elementAt(i);
if(r.呼叫类型.equals("本地主叫.虚拟网"))
{
//System.out.println(r.序号+" "+r.呼叫类型+" "+r.时长);
虚拟网呼出时间+= r.时长/60+1;
}
else if(r.呼叫类型.equals("本地被叫.虚拟网"))
{
虚拟网呼入时间+= r.时长/60+1;
}
else if(r.呼叫类型.equals("发短信(免).网内短信"))
{
网内短信条数++;
}
else if(r.呼叫类型.equals("发短信.网外短信"))
{
网外短信条数++;
}
else if(r.呼叫类型.equals("本地主叫."))
{
本地呼出时间+= r.时长/60+1;
}
else if(r.呼叫类型.equals("本地被叫."))
{
本地呼入时间+= r.时长/60+1;
}
}
}
private void print()
{
System.out.println("移动话费整理程序:Copyright——J.Fat");
System.out.println("本月至今的移动话费详细情况如下:");
System.out.println("虚拟网已使用:"+(虚拟网呼入时间+虚拟网呼出时间)+"分钟"+
"\n\t其中:呼出"+虚拟网呼出时间+"分钟"+
"\t呼入"+ 虚拟网呼入时间+"分钟"
+"\n本地通话时间:"+(本地呼出时间+本地呼入时间)+"分钟"
+"\n\t其中:呼出"+本地呼出时间+"分钟"
+"\t呼入"+本地呼入时间+"分钟"
+"\n网内短信条数:"+网内短信条数
+"\t网外短信条数:"+网外短信条数
);
}
public static void main(String [] args)
{
ChinaMobileExpenseStatistics cmes = new
ChinaMobileExpenseStatistics();
try{
cmes.file = new FileReader(args[0]);
}catch(FileNotFoundException e){
System.out.println("File not found!");
System.exit(-1);
}
try{
while(cmes.file.ready())
{
String no = cmes.getValue();
int 序号 = Integer.parseInt(no);
// System.out.println(序号);
String 日期 = cmes.getValue();
// System.out.println(日期);
String 时间 = cmes.getValue();
// System.out.println(时间);
String timeLength = cmes.getValue();
long 时长 = Integer.parseInt(timeLength);
// System.out.println(时长);
String 呼叫类型 = cmes.getValue();
// System.out.println(呼叫类型);
String 服务类型 = null;
// System.out.println(" ");
cmes.file.skip(2);
String moveExpense = cmes.getValue();
float 移动费 = Float.parseFloat(moveExpense);
// System.out.println(移动费);
String smsExpense = cmes.getValue();
float 长途或信息费 = Float.parseFloat(smsExpense);
// System.out.println(长途或信息费);
String tempTol = cmes.getValue();
float 小计 = Float.parseFloat(tempTol);
// System.out.println(小计);
String 通话地 = cmes.getValue();
// System.out.println(通话地);
String 对方号码 = cmes.getValue();
// System.out.println(对方号码);
cmes.file.skip(2);
cmes.all.add(new Record(序号 , 日期 , 时间 , 时长 , 呼叫类型 , 服务类型 , 移动费 , 长途或信息费 , 小计,通话地 , 对方号码));
}
cmes.file.close();
}catch(NumberFormatException e)
{
System.out.println("NumberFormatException1");
e.printStackTrace();
}catch(IOException e)
{
System.out.println("IOException in main()!");
}
cmes.compute();
cmes.print();
}
}
class Record
{
int 序号;
String 日期;
String 时间;
long 时长;
String 呼叫类型;
String 服务类型;
float 移动费;
float 长途或信息费;
float 小计;
String 通话地;
String 对方号码;
Record(int 序号 , String 日期 , String 时间 , long 时长 , String 呼叫类型 , String 服务类型 ,
float 移动费 , float 长途或信息费 , float 小计 , String 通话地 , String 对方号码)
{
this.序号=序号;
this.日期=日期;
this.时间=时间;
this.时长=时长;
this.呼叫类型=呼叫类型;
this.服务类型=服务类型;
this.移动费=移动费;
this.长途或信息费=长途或信息费;
this.小计=小计;
this.通话地=通话地;
this.对方号码=对方号码;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -