Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Help me to troubleshoot the errors

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Help me to troubleshoot the errors

    import java.io.DataInputStream;
    class Items
    {
    int itemcode[]=new int[10];
    int itemcoast[]=new int[10];
    int rem;
    int i,coast,counter;
    try
    {
    //Input Items
    void getitem()
    {

    System.out.println("Enter the item code");
    itemcode[counter]=Integer.parseInt(d.readLine());
    System.out.println("Enter the item cost");
    itemcost[counter]=Integer.parseInt(d.readLine());
    counter++;
    }
    //Total price
    void sumitemcoast()
    {
    for(i=0;i<counter;i++)
    {
    coast=coast+itemcoast[i];
    }
    }
    //to display current items and its coast
    void display()
    {
    System.out.println("Item code And Item Coast");
    for(i=0;i<counter;i++)
    {
    System.out.println(itemcode[i]+" "+itemcoast[i]);
    }
    }
    //remove item
    void remove()
    {
    System.out.println("Enter the item code you want to remove");
    rem=Integer.parseInt(d.readLine());
    for(i=0;i<counter;i++)
    {
    if(itemcode[i]==rem)
    {
    itemcoast[i]=0;
    break;
    }
    }
    }
    }
    catch (Exception e) { }
    }

    //main
    class Allitem
    {
    public static void main(String args[])
    {
    DataInputStream d=new DataInputStream(System.in);
    Items I=new Items();
    try
    {
    System.out.println("Press 1 to Enter Data \n Press 2 to display Item and Coast \n Press 3 to get total item coast \n Press 4 to remove item");
    x=Integer.parseInt(d.readLine());
    do
    {
    switch(x)
    {
    case 1:I.getitem();
    break;
    case 2:I.display();
    break;
    case 3:I.sumitemcoast();
    break;
    case 4:I.remove();
    break;
    }
    System.out.println("Enter 1 to stop or 0 to continue");
    int w=Integer.parseInt(d.readLine());
    }
    while(w!=0);
    }
    catch (Exception e){}
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Help me to troubleshoot the errors

    Please post questions in the correct section. This one is for introductions.

    When posting code wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    If you have errors, copy the full text of the error messages and post them here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help me to troubleshoot the errors

    Thread moved from Members Introductions

Similar Threads

  1. Game of Life Matrix...Needs troubleshoot, specific output
    By Eriosblood in forum Collections and Generics
    Replies: 12
    Last Post: September 11th, 2012, 10:59 PM
  2. Help With errors. Please.
    By wrx12 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 11th, 2012, 11:53 AM
  3. Replies: 3
    Last Post: March 6th, 2012, 03:50 AM
  4. Many Errors
    By Woody619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: July 16th, 2010, 09:36 PM
  5. Getting errors
    By Nonire in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 4th, 2010, 12:21 PM

Tags for this Thread