-4

我正在编写一个程序,该程序将允许一个零售商和多个买家进行购买的贷记和借记。在每个买家购买或进行 pmnt 后,我​​需要每月汇总每笔交易。
这是我所拥有的,此时我唯一的错误是:

Main.java:136: error: not a statement
                  displayprocestran;   
                  ^
Main.java:144: error: not a statement
                displayprostrans;
                ^

这是程序:

/*Project4B, Judith Berk, CIS 2110, 4/28/13*/

import java.io.*;

public class Project4BDriver 
{

    public void main(String args[]) throws IOException ;
    {
         Project4B app;
         app = new Project4B();
         app.appMain();
    }
} //end of class DriverProject4B

class Project4B 
{
     //Data declarations

     BufferedReader stdin;
     String custName;
     char transType;
     int transNum;
     float transAmt;
     float prcnt;
     float prcntChrg;
     float TprcntChrg;
     float runBal;
     float begBal;
     float endBal;
     float TPmnt;
     float TChrg;
     int PurchCtr;
     float HiPurchAmt;
     String HiPurchCust;
     float AvgPurch;
     float CoMonthBal;
     float CoTnewChrg;
     float CoTPmnt;
     float CobegBal;


    public void appMain() throws IOException ;
    {
        outputHeader();
        initReport();
        getAcctInfo();
        initrunBal();

        while (transNum != 0);
        {
             prostrans();
        }

         calculate average;
         calculate runBal;
         calculate interest;
         display summary;
    }

    void outputHeader();
    {
         //Output report header
         System.out.print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
         System.out.println("Project4B");
         System.out.println("Judith Berk CIS 2110");
         System.out.println("Supply Chain Monthly Report");
         System.out.print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
    }

    void initReport() 
    {
         //standard input will be keyboard
         stdin = new BufferedReader(new InputStreamReader.System.in());

         TPmnt = 0;
         TChrg = 0;
         PurchCtr = 0;
         PrcntChrg = 0;
         TprcntChrg = 0;
         hiPurchAmt = 0;
         CoMonthlyBal = 0;
    }

    public void getAcctInfo() throws IOException;
    {
         System.out.print("Please enter CUSTOMER NAME:");
         custName = (stdin.readLine());

         System.out.print("Please enter BEGINNING BALANCE for Customer:");
         begBal = Float.parseFloat(stdin.readLine());

         System.out.print("Please enter Customer's individual INTEREST RATE (i.e. 0.05, 0.03, 0.035):");
         prcnt = Float.parseFloat(stdin.readLine());
    }

    void initrunBal()

    {
         runBal = begBal;
    }

    public void prostrans() throws IOException;

    {
         get transNum;
    }

    public void gettransNum() throws IOException;

    {
         System.out.print("Please enter TRANSACTION NUMBER:");
         transNum = Integer.ParseInt(stdin.readLine());
    }

    public void gettransDetails() throws IOException;

    {
         System.out.print("Please enter TRANSACTION AMOUNT:");
         transAmt = Float.parseFloat(stdin.readLine());

         System.out.print("Please enter TRANSACTION TYPE:");
         transType = (stdin.readLine().charAt(0));
    }

    void  calcTPmntTChrgTPrcntChrgandrunBal();
    {

         if ((transType == "C") && (transType ==  "c"))
           {
                 purchCtr = purchCtr + 1;
                 prcntChrg = prcnt * transAmt;
                 runBal = runBal + transAmt + prcntChrg;
                 TChrg = TChrg + transAmt;
                 TprcntChrg = prcntChrg + prcntChrg;
                  displayprocestran;   
            } 


         else if ((transType == "p") && (transType ==  "P"))
            {
                 runBal = runBal - transAmt;
                 TPmnt = TPmnt + transAmt;
                displayprostrans;
            }



    }

    void displayprostran();
    {
         System.out.println("*\n" + custName);
         System.out.println("*\n" + transAmt);
         System.out.println("*\n" + runBal);
    }

    void updateHiPurchCustandHiPurchTot();
    {
        if (HiPurchAmt > TChrg);
            {
                 HiPurchChrg = TChrge;
                 HiPurchName = custName;
            }
    }

    void calcAvgPurch();
    {
         AvgPurch = TChrg / purchCtr;
    }

    void initCoMonthBal()
    {
         get CobegBal;
    }

    {
         System.out.print("Enter Company Beginning Balance");
         CobegBal = Float.parseFloat(stdin.readLine());
    }

    void calcCosummary();
    {
         CoMonthBal = CobegBal + TChrg - TPmnt;
    }

    void displaysummary()
    {
         System.out.print("Customer Name:\t" + custName);
         System.out.print("Customer Beginning Balance:\t" + begBal);
         System.out.print("Customer Payments:\t" + TPmnt);
         System.out.print("Customer New Charges:\t" + TChrg);
         System.out.print("Customer Interest Charge:\t" + TprcntChrg);
         System.out.print("Customer Ending balance:\t" + runBal);

         System.out.print("Overall Company Ending Balance:\t" + CoMonthlBal);
         System.out.print("Monthly Average Purchases:\t" + AvgChrg);
         System.out.print("Monthly Payments Received:\t" + TPmnts);
         System.out.print("Customer with highest monthly Purchases:\t" + HiPurchName);
         System.out.print("Highest Monthly Purchase Amount:\t" + HiPurchAmt);
    }
}

请帮我!

谢谢朱迪

4

2 回答 2

6

你的问题


 displayprocestran;  

绝对不是声明。也许你的意思是

  displayprocestran();

错误消息的旁注


起初,错误消息可能看起来有点神秘,但让我们看看你的。

 Main.java:136: error: not a statement displayprocestran;
Main.java:144: error: not a statement displayprostrans; ^

好吧,它告诉你它找到了^指向的错误,它位于displayprocestran. 它也告诉你这不是一个声明。这应该告诉您,您有语法错误,这意味着您输入错误。现在,您可以到处调用方法stdin.readLine()。您应该开始尝试建立有关为什么会出现这些错误的链接。


其他我注意到但我还没有提到的事情


命名

好吧,我想最大的问题是你的方法是多么难以理解。Java 命名约定解释了方法和变量的布局方式。例如:

displayprocestran --- > displayProcesTran (I think)

封装

你有这样的方法:

void initrunBal()
{
     runBal = begBal;
}

我不确定用户何时需要使用此方法。所以也许让它成为访问修饰符private。这是为了确保呈现给类用户的界面正是他们需要的方法。他们不需要知道你班级的内部运作。这叫做抽象

根本无法编译的东西

public void prostrans() throws IOException;
{
     get transNum;
}

那不是有效的Java。我实际上不确定你想要什么。也许你想回来transNum?在这种情况下,它应该是:

public int getTransNum()
{
    return transNum;
}
于 2013-05-02T21:50:50.653 回答
0

在以下代码中:

 if ((transType == "C") && (transType ==  "c"))
   {
         ...
         displayprocestran;   
    } 

您实际上是在尝试调用该void displayprostran()方法吗?如果是这样,这样称呼它

 if ((transType == "C") && (transType ==  "c"))
   {
         ...
         displayprostran();   
    } 
于 2013-05-02T21:51:07.217 回答