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 2 of 2

Thread: JAVA Error : Please check program and Correct Code : : I m a Learner in JAVA?

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA Error : Please check program and Correct Code : : I m a Learner in JAVA?

    a program to add,display,remove items :

    solution I did

    package com.TestJava;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;


    const int m=50;
    public : class items
    {
    int itemcode[m];
    float itemprice[m];
    int count;

    public:
    void cnt(void) {count=0;} //initializes count to 0
    void getitem(void);
    void displaysum(void);
    void remove(void);
    void displayitems(void);
    };

    //===================================…

    void items :: getitem(void) //assign values to data members of item
    {
    System.out println("Enter the item code:");
    catch(itemcode[count]);

    System.out println("Enter item cost");
    catch(itemprice[count]);
    count++;
    }

    void items ::displaysum(void) //display total values of all items
    {
    float sum=0;
    for(int i=0;i<count;i++)
    sum=sum+itemprice[i];

    System.out println("\n total value :" <<sum<< "\n");
    }

    void items :: remove(void) //delete the specific item
    {
    int a;
    System.out println("Enter the item code";
    catch(a);

    for (int i=0;i<count;i++)
    if(itemcode[i] ==a)
    itemprice[i] =0;
    }

    void items :: displayitems(void) //displaying item
    {
    System.out println("\n code price \n");
    for (int i=0;i<count; i++)
    {
    <<"\n" <<itemcode[i];
    System.out println(" " <<itemprice[i]);

    }

    System.out println("\n");

    }

    //===================================…


    int main()
    {
    items order;
    order.cnt();
    int x;
    do //do .... while loop
    {
    System.out println("\n you can do following \n Enter sppropriate number \n");


    System.out println ("\n1 :Add an ite");
    System.out println ("\n2 : Display total value");
    System.out println ("\n3 : delete an item");
    System.out println ("\n4 : display all item");
    System.out println ("\n5 : Quit");
    System.out println ("\n\n what is your option?");

    catch(x);

    switch(x)
    {
    case 1 : order.getitem();
    break;

    case 2 : order.displaysum();
    break;

    case 3 : order.remove();
    break;

    case 4 : order.displayitems();
    break;

    case 5 : break;
    default : System.out println("Error in input; try again\n");

    }
    }

    while(x !=5); //do ...while ends
    return 0;
    }
    }


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

    Default Re: JAVA Error : Please check program and Correct Code : : I m a Learner in JAVA?

    Please explain what the problem is.
    If you get errors, copy the full text and paste here.
    If the output is wrong, copy the output and add some comments explaining what is wrong and show what the output should be.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. GUI program won't take 'char' input code, can't seem to find the correct one...
    By Eclecstatic in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 1st, 2012, 07:12 AM
  2. Help me check my assignment if it is correct.
    By mamaass in forum What's Wrong With My Code?
    Replies: 22
    Last Post: June 19th, 2012, 09:14 AM
  3. java program check for files
    By Creeper in forum Java Theory & Questions
    Replies: 2
    Last Post: February 29th, 2012, 02:38 PM
  4. I am a new Java learner
    By shyland in forum Member Introductions
    Replies: 2
    Last Post: February 1st, 2012, 10:20 AM
  5. Java Program to Check whether a Expression is Valid using Stack
    By rainbow9 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 12th, 2011, 02:11 AM