Results 1 to 6 of 6
  1. #1
    xKxCx is offline Member
    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    Default Cannot figure out reason for error..

    I am getting the error Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: inventory.CD
    at inventory.Inventory.main(Inventory.java:13)
    Java Result: 1
    in NetBeans and I cannot figure out the reason.

    Java Code:
    /* Inventory Program
     * This program shows the amount of CD's in stock while also displaying the 
     * price per unit as well as the total price of all units.
     */
    package inventory;
    
    public class Inventory {
    
        //Starts the main application
        public static void main(String[] args) {
            
            //items in stock
            CD p1 = new CD(1,"Jealous Me Was Killed By Curiosity","Moros Eros",8,9.99 );
            CD p2 = new CD(2,"Music by Cavelight","Blockhead",12,11.99 );
            CD p3 = new CD(3,"Rubber Soul","The Beatles",4, 14.99 );
            CD p4 = new CD(4,"The Hooters","Amore",7,6.99 );
            
            // Display the information about products
            System.out.println(p1);
            System.out.println();
            System.out.println(p2);
            System.out.println();
            System.out.println(p3);
            System.out.println();
            System.out.println(p4);
            System.out.println();
        }
    }
    Java Code:
    /*
     * Public Constructor for Inventory Program
     * This Constructor takes the cdNumber as int, cdAlbum and cdBand as String's, 
     * quantity as int, and the price as double and then sets the base values of the 
     * item(s) in inventory.
     */
    
    public class CD 
    {
        
            int cdNumber;
            String cdAlbum;
            String cdBand;
            int quantity;
            double price;
        
            public CD(int number, String album, String band, int quantity, double MSRP)        
            {
                
                    cdNumber = number;
                    cdAlbum = album;
                    cdBand = band;
                    this.quantity = quantity;
                    price = MSRP;
                
           }
           // Returns identifier for item 
           public int getcdNumber() 
           {
                    return cdNumber;            
           }         
           // Sets identifier for item
           public void setcdNumber(int value)
           {        
                    cdNumber = value;       
           }         
           // Returns the name for the specific item       
           public String getcdAlbum()
           {        
                    return cdAlbum;                
           }
           // Returns the name for the specifc item
           public String getcdBand()
           {           
                    return cdBand;                
           }
           // Returns the amount of CD's in stock
           public int getQuantity()
           {           
                    return quantity;            
           }
           // Sets the number of CD's in stock
           public void setQuantity(int value)
           {           
                    quantity = value;         
           }
           // Returns price of CD
           public Double getPrice()
           {
                    return price;
           }
           // Sets the price for the CD 
           public void setPrice(double value)
           {
                    price = value;
           }
           // Calculates the total value of inventory for the item(s)
           public Double getInventoryValue()
           {
                    return getPrice() * getQuantity();        
           }
           // Returns the printout of the item to display on screen
           public String toString()
           {
                    return String.format("\nINVENTORY INFO\n%s %s\n%s\t %s\n%s\t %s\n%s\t %d\n%s\t $%, .2f\n%s\t S%, .2f","Product Number: ",getcdNumber(), 
                            "Product Name: ", getcdAlbum(), getcdBand(), "Units in Stock:", getQuantity(),
                            "Price per Unit:", getPrice(), "Total Inventory Value:", getInventoryValue());
           }
    }
    I know it is probably something very simple but I am fairly new to Java and all feedback would be much appreciated.
    Thanks.
    Last edited by xKxCx; 07-21-2013 at 10:03 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Cannot figure out reason for error..

    Quote Originally Posted by xKxCx View Post
    Cannot figure out reason for error..
    Please go through the Forum Rules, particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Cannot figure out reason for error..

    Quote Originally Posted by xKxCx View Post
    I am getting the error [COLOR="#B22222"]Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: inventory.CD
    Don't ever try to run code that can't be compiled. Try to compile that code and if you can't understand the compiler messages (most of them are fairly straightforward) copy and paste those compiler messages here.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    xKxCx is offline Member
    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    Default Re: Cannot figure out reason for error..

    Quote Originally Posted by DarrylBurke View Post
    Please go through the Forum Rules, particularly the third paragraph.

    db
    Thanks, and sorry for the first timer mistakes with the forum rules. I will be sure to post threads with proper titles.

  5. #5
    xKxCx is offline Member
    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    Default Re: Cannot figure out reason for error..

    Quote Originally Posted by DarrylBurke View Post
    Don't ever try to run code that can't be compiled. Try to compile that code and if you can't understand the compiler messages (most of them are fairly straightforward) copy and paste those compiler messages here.

    db
    Thanks Darryl, I never thought to compile first before running the program. I ran the "Clean and Build Project" through NetBeans and there was more errors than I knew of.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Cannot figure out reason for error..

    For your future coding: compile every time you add a few lines of code. Then if you get an error, you know exactly where to look.

    Never, never write hundreds or even dozens of lines of code without compiling along the way.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 9
    Last Post: 05-28-2013, 09:14 AM
  2. Replies: 6
    Last Post: 05-26-2013, 02:53 AM
  3. Cannot figure out error messages
    By Teclis in forum New To Java
    Replies: 6
    Last Post: 03-29-2011, 09:31 PM
  4. Can someone figure out this error for me
    By Dev23 in forum New To Java
    Replies: 2
    Last Post: 02-24-2011, 04:31 AM
  5. [SOLVED] Can't pinpoint reason for this error..
    By Reiyn in forum New To Java
    Replies: 6
    Last Post: 03-30-2009, 06:39 PM

Posting Permissions

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