• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

I keep getting an error message in my code

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

 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • 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
  • 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

 
Sheriff
Posts: 22040
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • 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: 4107
72
Hibernate Fedora Chrome
  • 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
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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.
 
Marshal
Posts: 71028
291
  • 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.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic