Java error! haven't seen solution elsewhere -
i writing program allow credit , debit of purchases 1 retailer , multiple buyers. after each buyer has purchased or made pmnt, need each transaction in monthly summary.
here have, error have @ point is:
main.java:136: error: not statement displayprocestran; ^ main.java:144: error: not statement displayprostrans; ^
this program:
/*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 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 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; { 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() { 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 highest monthly purchases:\t" + hipurchname); system.out.print("highest monthly purchase amount:\t" + hipurchamt); } }
please me!
thanks judy
problem
displayprocestran;
is not statement. perhaps mean
displayprocestran();
side note on error messages
@ first, error messages might seem little cryptic, let's @ your's.
main.java:136: error: not statement displayprocestran; main.java:144: error: not statement displayprostrans; ^
well, it's telling found error ^
points to, @ end of displayprocestran
. it's telling not statement. should tell you, have syntax error, means you've typed wrong. now, call methods stdin.readline()
on place. should start try , make link why you're getting these errors.
other things i've noticed haven't seen mentioned
naming
well, guess big 1 how unreadable methods are. java naming conventions explain how methods , variables should laid out. example:
displayprocestran --- > displayprocestran (i think)
encapsulation
you've got methods like:
void initrunbal() { runbal = begbal; }
i'm not sure when user need use method. perhaps making it's access modifier private
. ensuring interface presented users of classes, methods need. don't need know inner workings of class. that's called abstraction.
stuff won't compile
public void prostrans() throws ioexception; { transnum; }
that isn't valid java. i'm not sure want that. perhaps want return transnum
? in case, should be:
public int gettransnum() { return transnum; }
Comments
Post a Comment