This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Car Inventory Problems  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

First, I will apologize for the length of this. I have an assignment for a Inventory Program which I have a couple of errors that are causing me to lose sleep. I have been pulling an all-nighter on this, and I just can not seem to figure this one out.

The assignment overview:

Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.
Create a method to calculate the value of the entire inventory.
Create another method to sort the array items by the name of the product.

Here are the codes

Inventory2:


Here is the Car class:


Here are the errors I receive:

.\Car.java:89: cannot find symbol
symbol : variable Car
location: class Car
return (totalValue += Car[CarCount].getValue());
^
.\Car.java:89: inconvertible types
found : <nulltype>
required: float
return (totalValue += Car[CarCount].getValue());

Do I need to rewrite the whole program?
 
Bartender
Posts: 1817
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to rewrite the whole program...

Your syntax is a little off here....





Hope that helps!
Janeice

[EDIT] fixed a couple errors.... I misunderstood what you were trying to return....
 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin:

Just a couple of style issues: variable names should begin with a lowercase, so:

instead of:

You probably should eliminate lines 14-18, since line 35 will blow away that object.

John.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!