The Artima Developer Community
Sponsored Link

Java Answers Forum
Help Please

1 reply on 1 page. Most recent reply: Feb 14, 2005 2:49 AM by Maria

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jade

Posts: 1
Nickname: jade13
Registered: Feb, 2005

Help Please Posted: Feb 12, 2005 5:09 PM
Reply to this message Reply
Advertisement
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());
}


Maria

Posts: 1
Nickname: marilopes
Registered: Feb, 2005

Re: Help Please Posted: Feb 14, 2005 2:49 AM
Reply to this message Reply
Hi

} //end the first for loop

is where u are ending your main method
Check your ending brackets again

Flat View: This topic has 1 reply on 1 page
Topic: An unexpected exception has been detected in native code outside the VM. Previous Topic   Next Topic Topic: Java PrintComponents Setting Default Fonts...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use