Java错误!其他地方没见过解决方案

时间:2013-05-02 21:48:25

标签: java

我正在编写一个程序,允许一个零售商和多个买家的信用卡和借记卡。在每个买家购买或成为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);
    }
}

请帮助我!

谢谢朱迪

2 个答案:

答案 0 :(得分:6)


您的问题


 displayprocestran;  

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

  displayprocestran();

关于错误消息的附注

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

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

嗯,它告诉你它发现了^指向的错误,它位于displayprocestran的末尾。它也告诉你这不是一个声明。这应该告诉你,你有一个语法错误,这意味着你输错了。现在,您可以在所有地方调用stdin.readLine()等方法。你应该开始尝试建立为什么你得到这些错误的链接。


我注意到的其他事情我还没有见过


命名

嗯,我想最重要的是你的方法有多难以理解。 Java naming conventions解释了如何布置方法和变量。例如:

displayprocestran --- > displayProcesTran (I think)

封装

你有类似的方法:

void initrunBal()
{
     runBal = begBal;
}

我不确定用户何时需要使用此方法。所以也许制作它的访问修饰符private。这是关于确保向您的类的用户呈现的界面,只是他们需要的方法。他们不需要知道你班级的内部运作。这叫做abstraction

根本无法编译的东西

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

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

public int getTransNum()
{
    return transNum;
}

答案 1 :(得分:0)

在以下代码中:

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

您实际上是在尝试调用void displayprostran()方法吗?如果是这样,请将其称为

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