Hello everyone, I was wondering if someone could help me with a program. It is an array program in jGRASP. I have closed the if(codeIsValid) loop with two } but now it wont recognize the last two statements b/c its out of the main method I believe. its giving me an illegal start of expression error for the x in the for(x=0; x<5; ++x) line and an identifier expected in the println statement that follows. any help anyone could give would be great! :) I have copied the program below.
public class EventArray4 { static final double CORP_RATE = 75.99; static final double PRI_RATE = 47.99; static final double NON_PROF_RATE = 40.99; public static void main(String[] args) throws Exception { Event2[] someEvents = new Event2[5]; int x; char event = 'Z'; double rate = 0; boolean codeIsValid; char[] eventCode = {'C', 'P', 'N'}; double[] eventRate = {CORP_RATE, PRI_RATE, NON_PROF_RATE}; for(x=0; x<5; ++x) { System.out.println("Enter event type"); System.out.println("C for corporate"); System.out.println("P for private"); System.out.println("N for non-profit"); event = (char)System.in.read(); System.in.read(); //absorbs enter codeIsValid = false; for(int i=0; i<3; ++i) { if(event == eventCode) rate = eventRate; codeIsValid = true; i = 3; } } if(codeIsValid) someEvents[x] = new Event2(event, rate); else --x; } //end the first for loop for(x=0; x<5; ++x) System.out.println("Event " + (x + 1) + " " + someEvents[x].getEventType()+ " " + someEvents[x].getEventMinRate()); }