-
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?
-
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
-
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);
-
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));
}