This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TestScores

 
Curtis Bridges
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*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.
*
*
*Instructions:
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
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic