• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I keep getting an error message in my code

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//Class: IT/215 Week Five Inventory Program 1

 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79183
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic