File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I keep getting an error message in my code

 
Donna Gary
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//Class: IT/215 Week Five Inventory Program 1

 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Donna Gary

You don't have "unitPrice" member variable in the Television class but you try to use them through accessor method?

And next time make sure you post error message(s) so that people can easily see what the problem is.

 
Donna Gary
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry I forgot to post the error message a little frustrated.

C:\Documents and Settings\AdminUser\MyDocuments\InventoryPart1.java:81: ')' expected nf.formatsamsung.calculateInventoryTotal)); ^ 1 error Tool completed with exit code 1

 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not the error I get. I get 5 errors, three of which relate to missing field "unitPrice", one about a non-existing constructor (hint: your Television constructor has 4 parameters but you try to call it with 5), and one about missing method "calculateInventoryTotal()".
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I'll tell you what's wrong with the code in more detail...

If you compile the given code above you'll get total of five errors. Three of them are related to the member variable "unitprice" and one about the wrong constructor used in line 64 and the use of non existing method in line 76.

You have to define a member variable called "unitprice" as you've done with "itemNumber" etc..
As shown below you are using the Television constructor with five argument where the defined constructor only has four.

And you don't have a method named "calculateInventoryTotal()" in the Television class but you try to call that method in line 76.

Fix those issues then it should compile.

Edit: Rob has already given the tips about the code
 
Donna Gary
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your tips were helpful, I made corrections to the errors but now I am still getting 1 error as follows:

C:\Documents and Settings\AdminUser\My Documents\InventoryPart1.java:84: reached end of file while parsing
}
^
1 error

Tool completed with exit code 1
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means you have mismatched { and } somewhere in your code. Carefully look at all the braces in your code, and check if you open and close all of the blocks with braces correctly.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reached end of file when parsing usually means you have more {s than }s, but I can't see any such imbalanced {} in what you posted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic