import java.io.*;
import java.text.DecimalFormat;
public class moneyPrint {
/**
* @param args
* @throws IOException
*
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
// String[] s={"1;0;3;10","2;4;5;?","3;0;9;?","4;10;0;?",""};
System.out.println("请输入你想输入的行数:");
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int j=Integer.parseInt(in.readLine());
String[] s=new String[j+1];
inputData ind=new inputData();
ind.input(s);
bankCount bc=new bankCount();
bc.setData(s);
}
}
class inputData
{
public String[] input(String[] s)
{
System.out.println("输入样例");
System.out.println("流水记录ID;收入;支出;余额");
for (int i = 0; i < s.length; i++)
{
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
s[i] =in.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
}
return s;
}
}
class bankCount
{
public void setData(String[] s)
{
int i=0;
String line="";
String[] txt1 = null;
double[][] arrs=new double[s.length-1][4];
System.out.println("输出样例:");
System.out.println("流水记录ID;收入;支出;余额");
while ((line=s[i])!="") {
txt1=line.split(";");
if(txt1[3].equals("?"))
{
arrs[i][3]=arrs[i-1][3]-Double.parseDouble(txt1[2])+Double.parseDouble(txt1[1]);
for(int j=1;j<3;j++)
{
arrs[i][j]=Double.parseDouble(txt1[j]);
}
System.out.print(i+1);
for(int j=1;j<4;j++)
if(j<4)
{
System.out.print(";");
System.out.print(String.format("%.2f", arrs[i][j]));
}
}
else{
System.out.print(i+1);
for(int j=1;j<4;j++)
{
arrs[i][j]=Double.parseDouble(txt1[j]);
if(j<4)
{
System.out.print(";");
System.out.print(String.format("%.2f", arrs[i][j]));
}
}
}
System.out.println("");
i++;
}
}
}