35 Replies - 12869 Views - Last Post: 02 December 2009 - 05:54 PM
#1
Shopping Program
Posted 16 November 2009 - 06:03 PM
o Store
o Products (3 classes)
Attributes
• Price
• Description
• UPC
• Inventory
• Taxable(y/n)
Methods
• Purchase(qty)
o Return price
o Decrement inventory
• Getprice
• Getdescription
• Getupc
• Getquantity
• getTaxStatus
o CashRegister (Shopping Cart)
Static TAX_RATE=1.06
Static Class
Methods
• calculateTotal
• enter payment (dollar/cents)
• give change
o Currency
Static variables of currency and coin
o Main Class
Add items
Enter purchase
Enter payment
Replies To: Shopping Program
#2
Re: Shopping Program
Posted 16 November 2009 - 06:14 PM
P.S. There are many knowledgable people on here that are experts in all sorts of programming and development. If you want help, this is the place, but we like to see some good faith effort put in on your part, and then we are more than happy to walk you threw your issues.
This post has been edited by theautokustomizer: 16 November 2009 - 06:15 PM
#3
Re: Shopping Program
Posted 16 November 2009 - 06:17 PM
theautokustomizer, on 16 Nov, 2009 - 05:14 PM, said:
P.S. There are many knowledgable people on here that are experts in all sorts of programming and development. If you want help, this is the place, but we like to see some good faith effort put in on your part, and then we are more than happy to walk you threw your issues.
I understand the guidelines but i do not know where to start. If someone could help me even set up this program i would appreciate it. Thank you for your time.
#4
Re: Shopping Program
Posted 16 November 2009 - 06:18 PM
This post has been edited by theautokustomizer: 16 November 2009 - 06:22 PM
#5
Re: Shopping Program
Posted 16 November 2009 - 07:20 PM
#6
Re: Shopping Program
Posted 16 November 2009 - 07:50 PM
pbl, on 16 Nov, 2009 - 06:20 PM, said:
Tai Pan, he doesn't have any code to try and use BBCode....
00musdan, Perfect example... Most people who don't see you following the rules, just skip right threw post....
This post has been edited by theautokustomizer: 16 November 2009 - 07:51 PM
#8
Re: Shopping Program
Posted 16 November 2009 - 08:40 PM
#9
Re: Shopping Program
Posted 16 November 2009 - 09:11 PM
package cashregister;
public class CashRegister {
public CashRegister(double purchase, double payment){
purch=purchase;
pmt=payment;
double giveChange(double price, double pmt){
double change = pmt-price;
return pay;
}
}
}
This post has been edited by 00musdan: 16 November 2009 - 09:12 PM
#10
Re: Shopping Program
Posted 16 November 2009 - 10:08 PM
Here to put you on the right track
// forget the package statement for now
public class CashRegister {
// the amount in the cash register
double amount;
// a constructor to build a new CashRegister
CashRegister(double amount) {
this.amount = amount;
}
// a method to accept cash which return the change
double pay(double payment, double purchase) {
System.out.println("For a purchase of $ " + purchase + " I received $" + payment);
double change = payment - purchase;
amount += purchase;
System.out.println("Now I have $" + amount + " in my cash register");
return change;
}
// the method to test the whole thing
public static void main(String[] args) {
// build a new CashRegister with $ 1000.00
CashRegister cr = new CashRegister(1000.0);
double change = cr.pay(100.00, 55.55);
System.out.println("I received $" + change + " as change");
}
}
#11
Re: Shopping Program
Posted 17 November 2009 - 10:06 AM
00musdan, on 16 Nov, 2009 - 08:11 PM, said:
package cashregister;
public class CashRegister {
public CashRegister(double purchase, double payment){
purch=purchase;
pmt=payment;
double giveChange(double price, double pmt){
double change = pmt-price;
return pay;
}
}
}
Nobody was yelling at you.... There are alot of people who don't or won't put in any effort of their own, and expect other people to do the work for them. We just like to see some effort put it by you. Basically, take your time to try and figure out even the outline to your problem, and then post... Don't just post. BTW, pbl is an expert and a very helpful individual, and he should be respected as such...not to forget to mention a lot of others because they are all great as well. You seen what you wrote, and you get a very nice and detailed response...
#12
Re: Shopping Program
Posted 17 November 2009 - 12:12 PM
#13
Re: Shopping Program
Posted 17 November 2009 - 01:25 PM
public class StoreInventory
{
RetailItem inventory[] = new RetailItem[10];
public String addToInventory(RetailItem item)
{
for (int i = 0; i < inventory.length; i++) {
// Look for empty spot and put the item there.
if (inventory[i] == null) {
inventory[i] = item;
break;
}
}
return "Done";
}
public double getTotalPriceOfInventory()
{
double totalprice = 0.0;
for (RetailItem currentItem : inventory) {
if (currentItem != null) {
totalprice += currentItem.getPrice();
}
}
return totalprice;
}
public int getUnitsOnHand()
{
int unitsonHand = 0;
for (RetailItem currentItem : inventory) {
if (currentItem != null) {
unitsonHand += currentItem.getUnitsOnHand();
}
}
return unitsonHand;
}
}
}
And for my tester program....
public class Tester {
public static void main(String args[]) {
StoreInventory inventory = new StoreInventory();
RetailItem item = new RetailItem("jacket", 1, 23.00);
inventory.addToInventory(item);
Double total = inventory.getTotalPriceOfInventory();
System.out.println(total.toString());
}
}
I think im doing something wrong with trying to get all my classes to "talk" (tester, inventory, cash register)
#14
Re: Shopping Program
Posted 17 November 2009 - 01:42 PM
As far as your money goes, I would declare my pennies,nickels, etc in another method...
EDIT: And if you have more code, let us see it...
This post has been edited by theautokustomizer: 17 November 2009 - 01:43 PM
#15
Re: Shopping Program
Posted 17 November 2009 - 05:01 PM
theautokustomizer, on 17 Nov, 2009 - 12:42 PM, said:
As far as your money goes, I would declare my pennies,nickels, etc in another method...
EDIT: And if you have more code, let us see it...
What i have submitted is all i have... well the inventory, tester, and cash register. I think the problem is i dont have the all the right methods and i dont know how to include the cash register class pbl fixed earlier. I will try to start a currency class to declare the money as you suggested. THANKS FOR HELPING
This post has been edited by 00musdan: 17 November 2009 - 05:17 PM

New Topic/Question
Reply



MultiQuote



|