New to the forum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nexcompac
    New Member
    • May 2007
    • 22

    New to the forum

    Hello everyone. I am new to java and new to this forum. I am having troubles with finishing this program. I am getting the following errors when trying to compile the program:
    "Line 276: <identifier> expected

    Line 334: reached end of file while parsing"

    I am using a program called JCreatorLE workspace. Here is the code:
    [code=java]
    /*W6D4:ShowInven tory.java
    *
    * Mike McGrady, May 17, 2007, 6:00 pm
    *
    * List item number, product name, quantity, price per unit, value of product, and total value of inventory.
    */

    import java.util.Scann er;//program uses class Scanner

    //ShowInventory program
    public class ShowInventory

    { //main method begins execution of java application
    public static void main (String args[])
    {
    Scanner myScanner = new Scanner (System.in);

    //item name variable
    String itemName1 = cd;//item name for inventory of music cd
    String itemName2 = dvd;//item name for inventory of video media
    String itemName3 = book;//item name for inventory of printed media

    //item code variable
    int code1 = 1000;//item code assigned to music cds
    int code2 = 2000;//item code assigned to video media
    int code3 = 3000;//item code assigned to printed media

    //item quantity variable
    int quantity1 = 15;//number of music cds on-hand
    int quantity2 = 11;//number of video media on-hand
    int quantity3 = 27;//number of printed media on-hand

    //price of media variable
    double price1 = 14.99;//assigned price of music cd
    double price2 = 19.99;//assigned price of video media
    double price3 = 12.99;//assigned price of printed media


    //cd

    class CD
    {
    private String name;
    private int itemCode;
    private int itemQuantity;
    private double itemPrice;

    //constructor to initialize the item with the information provided
    public CD(String name, int itemCode, int itemQuantity, double itemPrice)
    {
    setName(name);
    setItemCode(ite mCode);
    setItemQuantity (itemQuantity);
    setItemPrice(it emPrice);
    }

    //get item name
    public String getName()
    {
    return this.name;
    }

    //set item name
    private void setName(String name)
    {
    this.name = name;
    }

    //set item code
    private void setItemCode(int itemCode)
    {
    this.itemCode = itemCode;
    }

    //set item quantity
    private void setItemQuantity (int itemQuantity)
    {
    this.itemQuanti ty = itemQuantity;
    }

    //set price of item
    private void setItemPrice (double itemPrice)
    {
    this.itemPrice = itemPrice;
    }

    //calculate value of item on-hand
    public double getItemValue()
    {
    return this.itemQuanti ty * this.itemPrice;
    }


    //DVD
    class DVD
    {
    private String name;
    private int itemCode;
    private int itemQuantity;
    private double itemPrice;

    //constructor to initialize the item with the information provided
    public DVD(String name, int itemCode, int itemQuantity, double itemPrice)
    {
    setName(name);
    setItemCode(ite mCode);
    setItemQuantity (itemQuantity);
    setItemPrice(it emPrice);
    }

    //get item name
    public String getName()
    {
    return this.name;
    }

    //set item name
    private void setName(String name)
    {
    this.name = name;
    }

    //set item code
    private void setItemCode(int itemCode)
    {
    this.itemCode = itemCode;
    }

    //set item quantity
    private void setItemQuantity (int itemQuantity)
    {
    this.itemQuanti ty = itemQuantity;
    }

    //set price of item
    private void setItemPrice (double itemPrice)
    {
    this.itemPrice = itemPrice;
    }

    //calculate value of item on-hand
    public double getItemValue()
    {
    return this.itemQuanti ty * this.itemPrice;
    }

    //book
    class Book
    {
    private String name;
    private int itemCode;
    private int itemQuantity;
    private double itemPrice;

    //constructor to initialize the item with the information provided
    public Book(String name, int itemCode, int itemQuantity, double itemPrice)
    {
    setName(name);
    setItemCode(ite mCode);
    setItemQuantity (itemQuantity);
    setItemPrice(it emPrice);
    }

    //get item name
    public String getName()
    {
    return this.name;
    }

    //set item name
    private void setName(String name)
    {
    this.name = name;
    }

    //set item code
    private void setItemCode(int itemCode)
    {
    this.itemCode = itemCode;
    }

    //set item quantity
    private void setItemQuantity (int itemQuantity)
    {
    this.itemQuanti ty = itemQuantity;
    }

    //set price of item
    private void setItemPrice (double itemPrice)
    {
    this.itemPrice = itemPrice;
    }

    //calculate value of item on-hand
    public double getItemValue()
    {
    return this.itemQuanti ty * this.itemPrice;
    }

    //calculate combined value of all inventory
    double inventoryValue = cdItemPrice + dvdItemPrice + bookItemPrice;



    //build array to house data
    //InitInventory.j ava
    public class InitInventory

    //initializer list specifies the value for each element
    {
    String inventory[] = {CD, DVD, Book};
    int itemcode [] = {1000, 2000, 3000};
    int itemquantity [] = {15,11,27};
    double itemprice [] = {14.99, 19.99, 12.99};
    double itemvalue [] = {15*14.99, 11*19.99, 27*12.99};

    System.out.prin tf("%s&s\n", "Index", "Value");//column headings

    //output each array elements value
    for (String counter = 0; counter < array.length; counter ++)
    System.out.prin tf("%5d%8d\n", counter, array[counter]);

    for (int counter = 0; counter < array.length; counter ++)
    System.out.prin tf("%5d%8d\n", counter, array[counter]);

    for (double counter = 0; counter < array.length; counter ++)
    System.out.prin tf("%5d%8d\n", counter, array[counter]);
    }//end class InitInventory

    }//end main


    }//end ShowInventory
    [/code]
    Last edited by RedSon; May 25 '07, 08:57 PM. Reason: Changed quote to code tags
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    #2
    Originally posted by nexcompac
    Hello everyone. I am new to java and new to this forum. I am having troubles with finishing this program. I am getting the following errors when trying to compile the program:
    "Line 276: <identifier> expected

    Line 334: reached end of file while parsing"

    I am using a program called JCreatorLE workspace. Here is the code:
    We have no ideal where line 276 amd 334 are at. Also please use Wrap Code tags #

    nomad
    Last edited by RedSon; May 25 '07, 08:57 PM. Reason: Finished quote tag

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      This code doesnt even go up that high.

      Comment

      • nexcompac
        New Member
        • May 2007
        • 22

        #4
        Originally posted by nomad
        Also please use Wrap Code tags #

        nomad
        What is a Wrap Code Tag?

        Comment

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          Originally posted by nexcompac
          What is a Wrap Code Tag?
          Click "Post Reply" and look on the right hand side of the screen.

          Comment

          • sandyw
            New Member
            • Mar 2007
            • 122

            #6
            Originally posted by nexcompac
            Hello everyone. I am new to java and new to this forum. I am having troubles with finishing this program. I am getting the following errors when trying to compile the program:
            "Line 276: <identifier> expected

            Line 334: reached end of file while parsing"

            I am using a program called JCreatorLE workspace. Here is the code:
            [code=java]
            /*W6D4:ShowInven tory.java
            *
            * Mike McGrady, May 17, 2007, 6:00 pm
            *
            * List item number, product name, quantity, price per unit, value of product, and total value of inventory.
            */

            import java.util.Scann er;//program uses class Scanner

            //ShowInventory program
            public class ShowInventory

            { //main method begins execution of java application
            public static void main (String args[])
            {
            Scanner myScanner = new Scanner (System.in);

            //item name variable
            String itemName1 = cd;//item name for inventory of music cd
            String itemName2 = dvd;//item name for inventory of video media
            String itemName3 = book;//item name for inventory of printed media

            //item code variable
            int code1 = 1000;//item code assigned to music cds
            int code2 = 2000;//item code assigned to video media
            int code3 = 3000;//item code assigned to printed media

            //item quantity variable
            int quantity1 = 15;//number of music cds on-hand
            int quantity2 = 11;//number of video media on-hand
            int quantity3 = 27;//number of printed media on-hand

            //price of media variable
            double price1 = 14.99;//assigned price of music cd
            double price2 = 19.99;//assigned price of video media
            double price3 = 12.99;//assigned price of printed media


            //cd

            class CD
            {
            private String name;
            private int itemCode;
            private int itemQuantity;
            private double itemPrice;

            //constructor to initialize the item with the information provided
            public CD(String name, int itemCode, int itemQuantity, double itemPrice)
            {
            setName(name);
            setItemCode(ite mCode);
            setItemQuantity (itemQuantity);
            setItemPrice(it emPrice);
            }

            //get item name
            public String getName()
            {
            return this.name;
            }

            //set item name
            private void setName(String name)
            {
            this.name = name;
            }

            //set item code
            private void setItemCode(int itemCode)
            {
            this.itemCode = itemCode;
            }

            //set item quantity
            private void setItemQuantity (int itemQuantity)
            {
            this.itemQuanti ty = itemQuantity;
            }

            //set price of item
            private void setItemPrice (double itemPrice)
            {
            this.itemPrice = itemPrice;
            }

            //calculate value of item on-hand
            public double getItemValue()
            {
            return this.itemQuanti ty * this.itemPrice;
            }


            //DVD
            class DVD
            {
            private String name;
            private int itemCode;
            private int itemQuantity;
            private double itemPrice;

            //constructor to initialize the item with the information provided
            public DVD(String name, int itemCode, int itemQuantity, double itemPrice)
            {
            setName(name);
            setItemCode(ite mCode);
            setItemQuantity (itemQuantity);
            setItemPrice(it emPrice);
            }

            //get item name
            public String getName()
            {
            return this.name;
            }

            //set item name
            private void setName(String name)
            {
            this.name = name;
            }

            //set item code
            private void setItemCode(int itemCode)
            {
            this.itemCode = itemCode;
            }

            //set item quantity
            private void setItemQuantity (int itemQuantity)
            {
            this.itemQuanti ty = itemQuantity;
            }

            //set price of item
            private void setItemPrice (double itemPrice)
            {
            this.itemPrice = itemPrice;
            }

            //calculate value of item on-hand
            public double getItemValue()
            {
            return this.itemQuanti ty * this.itemPrice;
            }

            //book
            class Book
            {
            private String name;
            private int itemCode;
            private int itemQuantity;
            private double itemPrice;

            //constructor to initialize the item with the information provided
            public Book(String name, int itemCode, int itemQuantity, double itemPrice)
            {
            setName(name);
            setItemCode(ite mCode);
            setItemQuantity (itemQuantity);
            setItemPrice(it emPrice);
            }

            //get item name
            public String getName()
            {
            return this.name;
            }

            //set item name
            private void setName(String name)
            {
            this.name = name;
            }

            //set item code
            private void setItemCode(int itemCode)
            {
            this.itemCode = itemCode;
            }

            //set item quantity
            private void setItemQuantity (int itemQuantity)
            {
            this.itemQuanti ty = itemQuantity;
            }

            //set price of item
            private void setItemPrice (double itemPrice)
            {
            this.itemPrice = itemPrice;
            }

            //calculate value of item on-hand
            public double getItemValue()
            {
            return this.itemQuanti ty * this.itemPrice;
            }

            //calculate combined value of all inventory
            double inventoryValue = cdItemPrice + dvdItemPrice + bookItemPrice;



            //build array to house data
            //InitInventory.j ava
            public class InitInventory

            //initializer list specifies the value for each element
            {
            String inventory[] = {CD, DVD, Book};
            int itemcode [] = {1000, 2000, 3000};
            int itemquantity [] = {15,11,27};
            double itemprice [] = {14.99, 19.99, 12.99};
            double itemvalue [] = {15*14.99, 11*19.99, 27*12.99};

            System.out.prin tf("%s&s\n", "Index", "Value");//column headings

            //output each array elements value
            for (String counter = 0; counter < array.length; counter ++)
            System.out.prin tf("%5d%8d\n", counter, array[counter]);

            for (int counter = 0; counter < array.length; counter ++)
            System.out.prin tf("%5d%8d\n", counter, array[counter]);

            for (double counter = 0; counter < array.length; counter ++)
            System.out.prin tf("%5d%8d\n", counter, array[counter]);
            }//end class InitInventory

            }//end main


            }//end ShowInventory
            [/code]
            I may be new to Java and I might not know what I'm talking about but why do you have all your data types, class in your
            public static void main (String args[])
            Shouldn't be in its own class?
            sandy

            Comment

            • nexcompac
              New Member
              • May 2007
              • 22

              #7
              Originally posted by nomad
              We have no ideal where line 276 amd 334 are at. Also please use Wrap Code tags #

              nomad
              Ok,
              Error: (217) invalid method declaratioin; return type required
              Error: (217) illegal start of type
              Error: (220) illegal start of type
              Error: (223) illegal start of type
              Error: (226) illegal start of type
              Error: (233) '}' expected

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by nexcompac
                Ok,
                Error: (217) invalid method declaratioin; return type required
                Error: (217) illegal start of type
                Error: (220) illegal start of type
                Error: (223) illegal start of type
                Error: (226) illegal start of type
                Error: (233) '}' expected
                Well then go ahead and check your braces. Are they matching?

                Comment

                Working...