Page 1 of 2 12 LastLast
Results 1 to 20 of 28
  1. #1
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default E:\IT 215 Java Programming\Inventory.java:178: cannot find symbol

    This is my share in part five of six programs for class 215. You can beleive that I am tired because you are tired. So lets get on with it.
    Java Code:
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.text.*;
    
    public class Inventory
    {
    // This constant is the max # of inventory items:
    public static final int maxItems = 10000;
    
    // main() method begins execution of a Java application:
    public static void main( String args[] )
    {
    // This flag will control whether we exit the loop below:
    boolean stop = false;
    
    // This array will hold the entire inventory:
    ProductWithLength inventory[] = new ProductWithLength[maxItems];
    
    // This counter will count the number of items in the inventory:
    int numItems = 0;
    
    // Loop until user indicates to exit the app:
    while (!stop)
    { 
    // Show title, and read product number and store in memory:
    String itemNumber = 
    JOptionPane.showInputDialog("Office Supply Inventory Program.\n\n " +
    "Please enter a new product number or press Cancel to end this program: "
    ); 
    
    // Check for user clicking Cancel:
    if (itemNumber == null)
    {
    // User clicked Cancel, set flag so we'll exit:
    stop = true;
    }
    else
    {
    // User did not click Cancel, so continue reading info for this iteration...
    
    float unitAmount = -1; // Number of units
    String unitAmountStr = ""; // String representation of # of units
    float price = -1; // Price of unit
    String priceStr = ""; // String representation of price
    float value; // Value of units multiplied by price
    int length = -1; // Length of product
    String lengthStr = ""; // String representation of length 
    
    // Prompt for and read product name:
    String productName = 
    JOptionPane.showInputDialog("Please enter the product name:\n\n"); 
    
    // Prompt for and read number of units, until a positive
    // value is entered:
    while (unitAmount <= 0)
    {
    unitAmountStr = JOptionPane.showInputDialog(
    "Please enter the number of units (value must be greater than 0):\n\n");
    
    try
    {
    unitAmount = Float.parseFloat(unitAmountStr); 
    }
    catch(Exception ex)
    {
    }
    }
    
    // Prompt for and read price per unit, until a positive 
    // value is entered:
    while (price <= 0)
    {
    priceStr = JOptionPane.showInputDialog(
    "Please enter the price per unit (value must be greater than 0):\n\n");
    
    try
    {
    price = Float.parseFloat(priceStr);
    }
    catch(Exception ex)
    {
    } 
    }
    
    // Prompt for and read length, until a positive 
    // value is entered:
    while (length <= 0)
    {
    lengthStr = JOptionPane.showInputDialog(
    "Please enter the length per unit (value must be greater than 0):\n\n");
    
    try
    {
    length = Integer.parseInt(lengthStr);
    }
    catch(Exception ex)
    {
    } 
    }
    
    // Now we know units, price and length are positive values.
    
    // Instantiate a ProductWithLength to hold this inventory item:
    ProductWithLength p1 = 
    new ProductWithLength(itemNumber, productName, unitAmount, price, length);
    
    // Add this Product to the inventory array:
    inventory[numItems] = p1;
    
    // Increment item counter:
    numItems++;
    }
    }
    
    // User has indicated to exit application...
    
    // Check for empty inventory:
    if (numItems == 0)
    {
    // No products in inventory...
    JOptionPane.showMessageDialog(null, 
    "No products were entered into the inventory.\n" +
    "Unable to display output.",
    "No Products Entered",
    JOptionPane.ERROR_MESSAGE);
    }
    else
    {
    // There are some products in inventory...
    
    // Trim the inventory array of all but actual Product objects:
    inventory = trimInventoryArray(inventory, numItems);
    
    // Sort the inventory array by product name:
    sortInventoryByName(inventory);
    
    // Display output for entire inventory...
    JOptionPane.showMessageDialog(null, 
    "Thank you for your input.\n" +
    "Please press OK for inventory display.",
    "Stop Request Received",
    JOptionPane.INFORMATION_MESSAGE);
    
    // Loop through inventory items and display info about each:
    for (int i=0; i < numItems; i++)
    {
    JOptionPane.showMessageDialog(
    null,
    // Product info:
    "Product Number: " + inventory[i].getitemNumber() + "\n" + // product #
    "Product Name: " + inventory[i].getproductName() + "\n" + // product name
    "Units in stock: " + inventory[i].getunitAmount() + "\n" + // # units
    "Length: " + inventory[i].getLength() + "\n" + // length
    String.format("Price of each unit: $%,.2f\n", inventory[i].getunitPrice()) + // unit price 
    String.format("Restocking fee: $%,.2f\n", inventory[i].getRestockingFee()) + // restocking fee
    String.format("Inventory value is $%,.2f\n", inventory[i].calculateValue()), // inventory value
    "Item #" + (i+1) + " of " + numItems, // this is the window title
    JOptionPane.INFORMATION_MESSAGE); 
    }
    
    // Display total inventory value:
    JOptionPane.showMessageDialog(null, 
    String.format("Value of entire inventory is $%,.2f\n", Inventory.calcEntireValue(inventory, numItems)),
    "Total Inventory Value",
    JOptionPane.INFORMATION_MESSAGE);
    }
    
    // Display ending message:
    JOptionPane.showMessageDialog(null, 
    "Thank you for using the Office Supply Inventory Program!",
    "Adios!",
    JOptionPane.PLAIN_MESSAGE);
    
    } // end method main
    
    // Trim inventory array to specified size:
    public static ProductWithLength[] trimInventoryArray(ProductWithLength[] inventory, int numItems)
    {
    ProductWithLength[] returnVal = new ProductWithLength[numItems];
    
    for (int i=0; i < numItems; i++)
    {
    returnVal[i] = inventory[i]; 
    }
    
    return returnVal;
    }
    
    // Calculate the value of the entire inventory. 
    public static float calcEntireValue(Product[] inven, int numItems)
    {
    float value = 0;
    
    // Loop through products and add their values to the total:
    for (int i=0; i < numItems; i++)
    {
    value += inven[i].calculateValue();
    }
    
    return value;
    }
    
    // Sort the inventory array by product name:
    public static void sortInventoryByName(Product[] inven)
    {
    Arrays.sort(inven);
    }
    
    } // end class Inventory
    [errors]
    E:\IT 215 Java Programming\Inventory.java:178: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    public static ProductWithLength[] trimInventoryArray(ProductWithLength[] inventory, int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:178: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    public static ProductWithLength[] trimInventoryArray(ProductWithLength[] inventory, int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:191: cannot find symbol
    symbol : class Product
    location: class Inventory
    public static float calcEntireValue(Product[] inven, int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:205: cannot find symbol
    symbol : class Product
    location: class Inventory
    public static void sortInventoryByName(Product[] inven)
    ^
    E:\IT 215 Java Programming\Inventory.java:18: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    ProductWithLength inventory[] = new ProductWithLength[maxItems];
    ^
    E:\IT 215 Java Programming\Inventory.java:18: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    ProductWithLength inventory[] = new ProductWithLength[maxItems];
    ^
    E:\IT 215 Java Programming\Inventory.java:105: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    ProductWithLength p1 =
    ^
    E:\IT 215 Java Programming\Inventory.java:106: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    new ProductWithLength(itemNumber, productName, unitAmount, price, length);
    ^
    E:\IT 215 Java Programming\Inventory.java:180: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    ProductWithLength[] returnVal = new ProductWithLength[numItems];
    ^
    E:\IT 215 Java Programming\Inventory.java:180: cannot find symbol
    symbol : class ProductWithLength
    location: class Inventory
    ProductWithLength[] returnVal = new ProductWithLength[numItems];
    ^
    E:\IT 215 Java Programming\Inventory.java:198: inconvertible types
    found : <nulltype>
    required: float
    value += inven[i].calculateValue();
    ^
    11 errors

    Tool completed with exit code 1
    [/errors]

  2. #2
    pellebye is offline Member
    Join Date
    Apr 2009
    Posts
    54
    Rep Power
    0

    Default

    I suggest you make a more simple case showing your problem ... sometimes that may also give you the solution of your problem. To find line 178 witout linenumbers is hard work.
    -
    Life is not the worst thing we have ... in a few minutes my coffee is ready.

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Surely by now you should have worked out what "cannot find symbol" means?
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  4. #4
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default made some changes to 11 errors now I have four errors

    Java Code:
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.JOptionPane;
    
    public class Inventory // line (7)
    {
    // This constant is the max # of inventory items:
    public static final int maxItems = 10000;
    
    // main() method begins execution of a Java application:
    public static void main( String args[] )
    {
    // This flag will control whether we exit the loop below:
    boolean stop = false;// line 16
    
    // This array will hold the entire inventory:
    ProductWithLength inventory[] = new ProductWithLength[maxItems];
    
    // This counter will count the number of items in the inventory:
    int numItems = 0;
    
    // Loop until user indicates to exit the app:
    while (!stop)
    {
    // Show title, and read product number and store in memory:
    String itemNumber =
    JOptionPane.showInputDialog("Office Supply Inventory Program.\n\n " +
    "Please enter a new product number or press Cancel to end this program: "
    ); // line 31
    
    // Check for user clicking Cancel:
    if (itemNumber == null)
    {
    // User clicked Cancel, set flag so we'll exit:
    stop = true;
    }
    else
    {
    // User did not click Cancel, so continue reading info for this iteration...
    
    float unitAmount = -1; // Number of units
    String unitAmountStr = ""; // String representation of # of units
    float price = -1; // Price of unit
    String priceStr = ""; // String representation of price
    float value; // Value of units multiplied by price
    int length = -1; // Length of product
    String lengthStr = ""; // String representation of length //line 49
    
    // Prompt for and read product name:
    String productName =
    JOptionPane.showInputDialog("Please enter the product name:\n\n");
    
    // Prompt for and read number of units, until a positive
    // value is entered:
    while (unitAmount <= 0)
    {
    unitAmountStr = JOptionPane.showInputDialog(
    "Please enter the number of units (value must be greater than 0):\n\n");
    
    try
    {// line 63
    unitAmount = Float.parseFloat(unitAmountStr);
    }
    catch(Exception ex)
    {
    }
    }
    
    // Prompt for and read price per unit, until a positive
    // value is entered:
    while (price <= 0)
    {
    priceStr = JOptionPane.showInputDialog(
    "Please enter the price per unit (value must be greater than 0):\n\n");
    
    try
    {
    price = Float.parseFloat(priceStr);
    }
    catch(Exception ex)
    {
    }
    }// line 85
    
    // Prompt for and read length, until a positive
    // value is entered:
    while (length <= 0)
    {
    lengthStr = JOptionPane.showInputDialog(
    "Please enter the length per unit (value must be greater than 0):\n\n");
    
    try
    {
    length = Integer.parseInt(lengthStr);
    }
    catch(Exception ex)
    {
    }// line 100
    }
    
    // Now we know units, price and length are positive values.
    
    // Instantiate a ProductWithLength to hold this inventory item:
    ProductWithLength p1 =
    new ProductWithLength(itemNumber, productName, unitAmount, price, length);
    
    // Add this Product to the inventory array:
    inventory[numItems] = p1;
    
    // Increment item counter:
    numItems++;
    }
    }// line 115
    
    // User has indicated to exit application...
    
    // Check for empty inventory:
    if (numItems == 0)
    {
    // No products in inventory...
    JOptionPane.showMessageDialog(null,
    "No products were entered into the inventory.\n" +
    "Unable to display output.",
    "No Products Entered",
    JOptionPane.ERROR_MESSAGE);
    }
    else
    {// line 130
    // There are some products in inventory...
    
    // Trim the inventory array of all but actual Product objects:
    inventory = trimInventoryArray(inventory, numItems);
    
    // Sort the inventory array by product name:
    sortInventoryByName(inventory);
    
    // Display output for entire inventory...
    JOptionPane.showMessageDialog(null,
    "Thank you for your input.\n" +
    "Please press OK for inventory display.",
    "Stop Request Received",
    JOptionPane.INFORMATION_MESSAGE);
    // line 145
    // Loop through inventory items and display info about each:
    for (int i=0; i < numItems; i++)
    {
    JOptionPane.showMessageDialog(
    null,
    // Product info:
    "Product Number: " + inventory[i].getitemNumber() + "\n" + // product #
    "Product Name: " + inventory[i].getproductName() + "\n" + // product name
    "Units in stock: " + inventory[i].getunitAmount() + "\n" + // # units
    "Length: " + inventory[i].getLength() + "\n" + // length
    String.format("Price of each unit: $%,.2f\n", inventory[i].getunitPrice()) + // unit price
    String.format("Restocking fee: $%,.2f\n", inventory[i].getRestockingFee()) + // restocking fee
    String.format("Inventory value is $%,.2f\n", inventory[i].calculateValue()), // inventory value
    "Item #" + (i+1) + " of " + numItems, // this is the window title
    JOptionPane.INFORMATION_MESSAGE);
    }
    
    // Display total inventory value:
    JOptionPane.showMessageDialog(null,
    String.format("Value of entire inventory is $%,.2f\n", Inventory.calcEntireValue(inventory, numItems)),
    "Total Inventory Value",
    JOptionPane.INFORMATION_MESSAGE);
    }
    
    // Display ending message:
    JOptionPane.showMessageDialog(null,
    "Thank you for using the Office Supply Inventory Program!",
    "Adios!",
    JOptionPane.PLAIN_MESSAGE);
    
    } // end method main
    
    // Trim inventory array to specified size:
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    {// line 179
    ProductWithLength[] length = new ProductWithLength[numItems];
    
    for (int num=1; i < numItems; num++)
    {
    returnVal[i] = inventory[i];
    }
    
    return returnVal;
    }
    
    // Calculate the value of the entire inventory. // line 190
    public static float calcEntireValue(Product[] inven, int numItems)
    {
    float value = 0;
    
    // Loop through products and add their values to the total:
    for (int i=0; i < numItems; i++)
    {
    value += inven[i].calculateValue();
    }
    // line 200
    return value;
    }
    
    // Sort the inventory array by product name:
    public static void sortInventoryByName(Product[] inven)
    {
    Arrays.sort(inven);
    }
    
    } // end class Inventory // line 210
    [errors]
    E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:179: '.class' expected
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    ^
    4 errors

    Tool completed with exit code 1
    Try it again. Thank you. Almost done until next Java class working for my bachelors degree. Thank you again.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Quote Originally Posted by tlouvierre View Post
    E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    ^
    4 errors

    Tool completed with exit code 1
    Try it again. Thank you. Almost done until next Java class working for my bachelors degree. Thank you again.
    Are you asking why it's an error?
    I mean...look at that line, and think about really, really basic Java syntax and why that line could be wrong.

    Also, could you format your code? It's not exactly easy to read.

  6. #6
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default What is it?

    Java Code:
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
    Yes, look at that line, very carefully...
    • It has a closing parentesis ... where is the opening parentesis?
    • Is the line the begining of a method? If so, what are the arguments being passed to the method and was is the type that it is returning?
    • If it's something else, please explain.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  7. #7
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default Code and errors

    Java Code:
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems) // line 1
    
    {// line 179
    ProductWithLength[] = new ProductWithLength[number]; // line two of one
    
    for (int number=1; number<10000;  number++) // line three of one
    I know this is where my problem lies. The first line is asking for a 'class'. So implement class inbetween public and static and I get the same ole errors. Nothing changes. Besides that I rewritten the code as "public static ProductWithLength[]; Inventory.ProductWithLength; number; and I am still told that it is wrong somewhere adn I have worked on the for loop because you should have seen it before it was all out of wake but I have a feeling once I clear up the line one problem the line three problem will show up again. Any suggestions? It is supposed to be a method. I think the parenthesis was type o. At the time of writing it it sounded normal but it looks at little trumped up now. Still working on it. I have looked and compared the method and for loop to others that I have accomplished and in variance the differ mildly, because they are different programs.

  8. #8
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    Hello, How are you today?
    I just noticed that certain members or moderators are from different parts of the world. That is awesome. I heard that there was an earthquake in Honduras but your in Mexico. How's the weather?

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Quote Originally Posted by tlouvierre View Post
    Java Code:
    public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems) // line 1
    
    {// line 179
    ProductWithLength[] = new ProductWithLength[number]; // line two of one
    
    for (int number=1; number<10000;  number++) // line three of one
    I know this is where my problem lies. The first line is asking for a 'class'. So implement class inbetween public and static and I get the same ole errors. Nothing changes. Besides that I rewritten the code as "public static ProductWithLength[]; Inventory.ProductWithLength; number; and I am still told that it is wrong somewhere adn I have worked on the for loop because you should have seen it before it was all out of wake but I have a feeling once I clear up the line one problem the line three problem will show up again. Any suggestions? It is supposed to be a method. I think the parenthesis was type o. At the time of writing it it sounded normal but it looks at little trumped up now. Still working on it. I have looked and compared the method and for loop to others that I have accomplished and in variance the differ mildly, because they are different programs.
    No no no no no no no.

    Ignore the specifics of the error message in this case...it's the compiler going "I haven't got a clue what you're trying to do here, but here's my set of best guesses". More often than not, with a line as wrong as this one, simply trying to follow what the compiler says will simply get you more errors, and code that is more wrong than a wrong thing.

    If you can't see what's wrong with that line, without looking at the compiler, then you really need to go back to basics on Java syntax. What a class looks like, what it contains, how you declare it...and in this case (I suspect) what a method should look like.

    Since you're new to all this, you should have one class per file. Don't even think about going down the road of inner classes or any of that stuff. Consequently should you get errors like this you'll know there's something very wrong with your code, and won't flail around trying to add classes where they're not needed.

    So, a class looks like:

    Java Code:
    public class MyClass
    {
       // list of attributes
       // my methods
    }
    An attribute declaration looks like:

    Java Code:
    private String myAttribute;
    A method looks like:

    Java Code:
    public String doSomething(int someParameter, String anotherParameter)
    {
        // Some code that does stuff
    }

  10. #10
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default Tolls method

    Java Code:
    // Trim inventory array to specified size:
    public static void main (String[] args)
    {(Product[] Inventory.Product[] = int number)}
    
    {// line 179
    Product[] = new Inventory.Product[int];}
    
    for (int number=1; number<10000;  number++)
    {
    returnVal[int] = inventory[int];
    }
    [errors]
    E:\IT 215 Java Programming\Inventory.java:180: ')' expected
    {(Product[] Inventory.Product[] = int number)}
    ^
    E:\IT 215 Java Programming\Inventory.java:180: '.class' expected
    {(Product[] Inventory.Product[] = int number)}
    ^
    E:\IT 215 Java Programming\Inventory.java:180: '.class' expected
    {(Product[] Inventory.Product[] = int number)}
    ^
    E:\IT 215 Java Programming\Inventory.java:180: illegal start of expression
    {(Product[] Inventory.Product[] = int number)}
    ^
    E:\IT 215 Java Programming\Inventory.java:180: ';' expected
    {(Product[] Inventory.Product[] = int number)}
    ^
    E:\IT 215 Java Programming\Inventory.java:183: not a statement
    Product[] = new Inventory.Product[int];}
    ^
    E:\IT 215 Java Programming\Inventory.java:183: ';' expected
    Product[] = new Inventory.Product[int];}
    ^
    E:\IT 215 Java Programming\Inventory.java:183: '.class' expected
    Product[] = new Inventory.Product[int];}
    ^
    E:\IT 215 Java Programming\Inventory.java:183: not a statement
    Product[] = new Inventory.Product[int];}
    ^
    E:\IT 215 Java Programming\Inventory.java:187: '.class' expected
    returnVal[int] = inventory[int];
    ^
    E:\IT 215 Java Programming\Inventory.java:187: '.class' expected
    returnVal[int] = inventory[int];
    ^
    11 errors

    Tool completed with exit code 1
    [errors]:confused:

  11. #11
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    STOP PROGRAMMING

    Seriously, do not touch a text editor or IDE until you've gone away and learnt the basics of Java syntax. The mind boggles at how you've managed to get all the way to part 5.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  12. #12
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Study methods...

    tlouvierre... please don't take this the wrong way, but I think your trying to bite too much off without understanding the basics. Comments like:
    I rewritten the code as "public static ProductWithLength[]; Inventory.ProductWithLength; number;
    and
    It is supposed to be a method.
    ... indicate to me that you don't know what your doing. The above doesn't come close to being a method and confuses the hell out of the compiler.
    I suggest you look at the following to understand what a method should looks like and how it works:

    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Returning a Value from a Method (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Quote Originally Posted by tlouvierre View Post
    Java Code:
    // Trim inventory array to specified size:
    public static void main (String[] args)
    {(Product[] Inventory.Product[] = int number)}
    
    {// line 179
    Product[] = new Inventory.Product[int];}
    
    for (int number=1; number<10000;  number++)
    {
    returnVal[int] = inventory[int];
    }
    That looks nothing like the templates I put up there, does it...

    Go with the links CJSLMAN has posted and learn the basics, honestly.

    ETA: Out of curiosity, what languages (if any) have you coded in before, including scripting ones. It might give us a clue as to why you're coding like this.

  14. #14
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default comments

    Quote Originally Posted by OrangeDog View Post
    Surely by now you should have worked out what "cannot find symbol" means?
    You are not a very nice person. Everyone has to start somewher and I am sorry that you can not have patients with a fellow member. I hope that you have not kids. I feel sorry for them.

  15. #15
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    There is nothing wrong with my coding and no I am not on drugs. The refurbished items that I have attempted work just fine in other programs. Why don't they work on this one? Same thing I rewrote the for loop and looks decent. Not enough sleep is my drug of choice. So I made a mistake and need to fix it and I must know what I am talking about if I can get four programs to compile and you can get even one. So much for getting help from Java Forums. I try and initiate conversation and all I get are insults. Thanks but no thanks give me back Singboyo at least he leads me in the right direction!

  16. #16
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    Java Code:
    // Trim inventory array to specified size:
    public double ProductWithLength (double ProductWith Length, int Inventory, double length, double inventory) 
    {// line 179
    Product[] = new Inventory.Product[int];}
    
    for (int number=1; number<10000;  number++)
    {
    returnVal[int] = inventory[int];
    }
    
    return returnVal;

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Quote Originally Posted by tlouvierre View Post
    Java Code:
    // Trim inventory array to specified size:
    public double ProductWithLength (double ProductWith Length, int Inventory, double length, double inventory) 
    {// line 179
    Product[] = new Inventory.Product[int];}
    
    for (int number=1; number<10000;  number++)
    {
    returnVal[int] = inventory[int];
    }
    
    return returnVal;
    Assuming the above is supposed to be a metjhod, can you, without reading the compiler errors it produces, tell us why it isn't correct?
    As a starter, look at the curly brackets.

  18. #18
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    Java Code:
    // Calculate the value of the entire inventory. // line 190
    public static class ProductWithLength // definition of class
    {// line 179
    ProductWithLength[] length = new ProductWithLength[numItems];}
    
    for (int i=1; i<10000;  i++)
    {
    returnVal[i] = inventory[i];
    }
    
    return returnVal;
    }
    [errors]
    E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: ')' expected
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: ';' expected
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:186: '(' expected
    for (int i=1; i<10000; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:191: illegal start of type
    return returnVal;
    ^
    E:\IT 215 Java Programming\Inventory.java:191: ';' expected
    return returnVal;
    ^
    E:\IT 215 Java Programming\Inventory.java:193: class, interface, or enum expected
    public static float calcEntireValue(Product[] inven, int numItems)
    ^
    E:\IT 215 Java Programming\Inventory.java:198: class, interface, or enum expected
    for (int i=0; i < numItems; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:198: class, interface, or enum expected
    for (int i=0; i < numItems; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:198: class, interface, or enum expected
    for (int i=0; i < numItems; i++)
    ^
    E:\IT 215 Java Programming\Inventory.java:201: class, interface, or enum expected
    }
    ^
    E:\IT 215 Java Programming\Inventory.java:204: class, interface, or enum expected
    }
    ^
    E:\IT 215 Java Programming\Inventory.java:207: class, interface, or enum expected
    public static void sortInventoryByName(Product[] inven)
    ^
    E:\IT 215 Java Programming\Inventory.java:210: class, interface, or enum expected
    }
    ^
    18 errors

    Tool completed with exit code 1
    [errors]




    Turns out it was a class because the following line did not pose any errors. I did read the literature that you gave me but none of it made since. Not for what the program holts and no I don't drink. Not even Nyquil. I have been walking around in this fog for a couple of days and can't seem to shake it. I you have no respect for me. So enough for both of us. Hah.

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Quote Originally Posted by tlouvierre View Post
    Turns out it was a class because the following line did not pose any errors. I did read the literature that you gave me but none of it made since. Not for what the program holts and no I don't drink. Not even Nyquil. I have been walking around in this fog for a couple of days and can't seem to shake it. I you have no respect for me. So enough for both of us. Hah.
    I doubt it's a class.

    Your class, as posted in the original post, is Inventory. Presumably sitting in a file Inventory.java.

    Re-read my earlier post where I showed you what the (basic) structure of a Class (and its components) is.

    Go through you Inventory class and restructure it so it matches that structure. Stop trying to fix the compiler errors that you're seeing, since they are the sort of massed errors you get when there is something fundamentally wrong with what's in your code.

  20. #20
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Smile logistics

    Quote Originally Posted by Tolls View Post
    Are you asking why it's an error?
    I mean...look at that line, and think about really, really basic Java syntax and why that line could be wrong.

    Also, could you format your code? It's not exactly easy to read.
    I am not asking why it is an error. I mean I know it is an error but in my head it is logical but in reality it is an error. I solved the error but am left with more errors to a basic for loop... I have tried every thing to get this for loop to be kosher but it just won't gel. Take a look.
    [code]
    public static class ProductWithLength // definition of class
    {// line 179
    ProductWithLength[] length = new ProductWithLength[numItems];}

    for (int i=0; i<10000; i++)// line 186
    {
    returnVal[i] = inventory[i];
    }
    [code]
    [errors]
    E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: ')' expected
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: ';' expected
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
    for (int i=0; i<10000; i++)// line 186
    ^
    E:\IT 215 Java Programming\Inventory.java:186: '(' expected
    for (int i=0; i<10000; i++)// line 186
    ^
    I have tried (int num=1; ProductWithLength<10000; numItems++), I have tried (int i=0, i<length; i++). I have just switching around the numbers and lengths and I get no where. I mean I wrote in a basic for loop as a reference to go back and solve the issue but I am not invisioning that now. Can you help out? At least lead me in the right direction.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 21
    Last Post: 06-01-2009, 12:52 PM
  2. Replies: 1
    Last Post: 05-31-2009, 06:48 PM
  3. Replies: 16
    Last Post: 05-28-2009, 03:41 PM
  4. java:34:cannot find symbol
    By MissyMadi in forum New To Java
    Replies: 5
    Last Post: 11-09-2008, 06:53 PM
  5. [SOLVED] Java Error: Cannot find Symbol...
    By bobleny in forum New To Java
    Replies: 8
    Last Post: 04-15-2008, 06:35 AM

Posting Permissions

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