Jump to content


New To Making Programs


  • Please log in to reply
2 replies to this topic

#1 Doug C.

Doug C.

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 15 May 2012 - 01:08 AM

This is my first semester taking programming design and I ran into a small problem. The program calls for using arrays and for some reason I keep getting the '.class' expected error message. When I go to build output it shows the error is the + symbol with the array.

Here is what I have so far.

Line

32       int hrsWorked[] = new int[5];


56       totalHoursWorked = hrsWorked[] + totalHrsWorked;





Our unstructor mainly shows us how to write psuedocode and then he does the programs on the overhead without really explaining the steps to solve these type of errors. Would greatly appreciate any help because this will not build the way it is.

#2 Kraicheck

Kraicheck

    Advanced Member

  • Members
  • PipPipPip
  • 880 posts
  • Gender:Male
  • Location:Belgium

Posted 15 May 2012 - 06:33 AM

You can't sum arrays.
What you need to do, is loop over your array using a for-loop and add each element to your totalHoursWorked.

#3 Doug C.

Doug C.

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 16 May 2012 - 02:57 AM

Thanks. I appreciate the help.