Results 1 to 7 of 7
  1. #1
    javadummy1 is offline Member
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Default Cannot Find Symbol Error

    I cannot figure out what to do to fix this error. Here is my code, this is my first time posting so I am not sure how to correctly post this, sorry. The line I am getting the error on is total = inv.getInventoryValue();

    class Inventory {



    String number; //stores DVD number
    String name; //stores DVD name
    int quantity; //stores quanity in stock
    float price; //stores DVD price
    float restockFee; //stores product restocking fee


    public Inventory(String ItemNumber, String ProductName, int units, float SellingPrice, float fee)
    {
    name = ProductName;
    number = ItemNumber;
    quantity = units;
    price = SellingPrice;
    restockFee = fee;
    }


    public void setName(String ProductName) //Method to set and get the product name
    {
    name = ProductName;
    }
    public String getName()
    {
    return name;
    }


    public void setNumber(String ItemNumber) //Method to set and get the product number
    {
    number = ItemNumber;
    }
    public String getNumber()
    {
    return number;
    }


    public void setQuantity(int units) //Method to set and get the quantity in stock
    {
    quantity = units;
    }
    public int getQuantity()
    {
    return quantity;
    }

    public void setPrice(float SellingPrice) //Method to set and get the price of product
    {
    price = SellingPrice;
    }
    public double getPrice()
    {
    return price;
    }


    public void setRestockFee(float fee) //Method to set and get the product restocking fee
    {
    restockFee = fee;
    }
    public double getRestockFee()
    {
    return restockFee;
    }


    public float getInventoryValue() //Method to calculate the value of the DVD's in stock
    {
    return price * quantity;
    }


    public static double getTotalValueOfAllInventory(Inventory [] inv)
    {

    double total = 0.00;

    for(int i = 0; i < inv.length; i++)
    {
    total = inv.getInventoryValue();
    }
    return total;
    }


    @Override
    public String toString()
    {
    return ""+name + "\t "+number+"\t $"+price+"\t "+quantity + "\t $"+getInventoryValue();
    }


    } // end Inventory Class

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    post the EXACT error message. Also, when posting code surround it in code tags.
    [ code]
    YOUR CODE HERE
    [/code]

  3. #3
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    275
    Rep Power
    4

    Default

    What for this inv is? You don't need this.

    Java Code:
    total = [B]inv.[/B]getInventoryValue();
    Don't pay attention to this answer, I just saw abowe line...
    Last edited by milovan; 04-09-2011 at 09:15 AM.

  4. #4
    baf06 is offline Member
    Join Date
    Jan 2011
    Location
    Beirut, Lebanon
    Posts
    90
    Rep Power
    0

    Default

    total = inv.getInventoryValue();
    inv.getInventoryValue(); reader the whole list, thus to solve this problem you have to specify which element of the list inv[] you are reading.

  5. #5
    baf06 is offline Member
    Join Date
    Jan 2011
    Location
    Beirut, Lebanon
    Posts
    90
    Rep Power
    0

    Default

    solving this issue is easy and simple, and remember that you have to read the elements of the array to be able to get its InventoryVAlue

  6. #6
    baf06 is offline Member
    Join Date
    Jan 2011
    Location
    Beirut, Lebanon
    Posts
    90
    Rep Power
    0

    Default

    yes and one m
    ore thing
    public double getPrice()
    {
    return price;
    }
    i think it is supposed to be a float since the price is a float and not a double

  7. #7
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    Quote Originally Posted by baf06 View Post
    yes and one m
    ore thing


    i think it is supposed to be a float since the price is a float and not a double
    rather, floats aren't accurate enough for prices and it is highly recommended that the price declaration be changed to a double type.

Similar Threads

  1. Please help- Error: cannot find symbol
    By Avthar in forum New To Java
    Replies: 4
    Last Post: 02-28-2011, 07:34 AM
  2. error cannot find symbol
    By jcoon3 in forum New To Java
    Replies: 3
    Last Post: 09-27-2009, 10:56 PM
  3. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  4. 'Cannot find symbol' error
    By minihazard10 in forum New To Java
    Replies: 6
    Last Post: 10-10-2008, 04:05 AM
  5. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •