File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes TestScores Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "TestScores" Watch "TestScores" New topic


Curtis Bridges

Joined: Jul 26, 2007
Posts: 9
/*Please help. I'm trying to throw an IllegalArgumentException.
*If any test score in the array is negative or greater than 100
*using a try block, but am having little if any progress after 9 hours of work.
* I am still getting an error mesage saying illegal start of expression and ) expected on line 48.
*The program will compute the average and display an Error invalid Score!message for average over 100
* but only calculates the - average without the Error invalid Score! message.
*Please help to make this work.
Write a class named TestScores.
The class constructor should accept an array of test scores as its argument.
The class should have a method that returns the average of the test scores.
If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException.
Demonstrate the class in a program.

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2068
Originally posted by Curtis Bridges:

Most likely, it is a missing or extra ( ) { or }.

Your try, catch, and finally are the ones involved. Bad syntax. Try see samples of try catch blocks to see correct matching of those delimiters, especially { and }.
Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

Originally posted by Curtis Bridges:
/*Please help. I'm trying to throw an IllegalArgumentException.

Problem isolation is all about removing stuff until it works and then
adding back in stuff until it breaks.

Hack out 90% of your code, specifically all the details on grades, to get the code to be under 15 lines.

Then add stuff back slowly.
I agree. Here's the link:
subject: TestScores
It's not a secret anymore!