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

Thread: JAVA HELP PLS!

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA HELP PLS!

    So We will create a java program but i don't know how to start it. We should use OOP in this one. And there should be minimum of 3 classes (including the main)..

    Buy n’ Sell

    An electronics and appliance store would like to install a kiosk for customer use. The kiosk allows the customer to take a look at available products for purchase or to sell his or her used but not defective gadget or appliance. You are asked to write a program for the said kiosk.

    The program should do the following:
    1.) Prompts the user if he or she wishes to buy or sell a product
    2.) If the customer wants to buy, display available products for purchase
    3.) Before user picks a product for purchase, prompts the user first for amount of cash in hand.
    4.) After transaction, displays the products bought, cash paid, and change.
    5.) If the user wants to sell a product, prompts user what type of product to sell.
    6.) Prompts user for amount of the product to sell.
    7.) After transaction, displays the product sold, amount of product, and payment from the transaction

    There is the problem. I hope you can help me on HOW TO START my program.. Any ideas please?


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

    Default Re: JAVA HELP PLS!

    We can help but just posting a homework assignment is never a way to get an answer other than the following...

    No one is going to do this for you. Make an effort to get started, and if you have questions along the way we can try to help if you post code, questions, and all error messages. If you are completely lost, start here: Java Tutorials

  3. #3
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: JAVA HELP PLS!

    Not sure if you're using console or JOptionPane, but

    use a char

    char c = 'c';
    String str = "";

    System.out.println("Enter a Y for yes or N for no");
    str = console.nextLine();

    c = str.charAt(0);

  4. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: JAVA HELP PLS!

    Also, can the user buy and sell many times?

    If so, I have an idea.

    Preferably use an ArrayList, though you could use a Vector I suppose.

    Have an ArrayList of products.

    Say you start out with
    Hand saw - 25
    Cotton Candy -100
    Garden Tools - 49
    Lightsabers - 3


    ArrayList<String> items = new ArrayList<String>();
    ArrayList<Integer> quantities = new ArrayList<Integer>();

    // I'm using them in order so the first value is the index in the ArrayList
    items.add(0, "Hand saw");
    quantities.add(0, 25);
    items.add(1, "Cotton Candy");
    quantities.add(1, 100);
    items.add(2, "Garden Tools");
    quantities.add(2, 49);
    items.add(3, "Lightsabers");
    quantities.add(3, 3);

    Then

    System.out.println("We have the following items:");

    for (int i =0; i < items.size(); i++)
    {
    System.out.println("Item " + (i+1) + " - " + items.get(i) + "- quantity " + quantities.get(i));
    }
    Last edited by javapenguin; December 8th, 2010 at 02:10 PM.