Shopping Program

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

35 Replies - 12869 Views - Last Post: 02 December 2009 - 05:54 PM Rate Topic: -----

#1 00musdan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 16-November 09

Shopping Program

Post icon  Posted 16 November 2009 - 06:03 PM

[size=7]Hello and Thank you Anyone who is about to help. I have a project in Java and I'm not sure how to do it or even where to begin. It is a program for a store. The following is what the teacher has given us as requirements.
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

Is This A Good Question/Topic? 0
  • +

Replies To: Shopping Program

#2 theautokustomizer   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 250
  • Joined: 20-September 09

Re: Shopping Program

Posted 16 November 2009 - 06:14 PM

We here at D.I.C. have a policy in which we like to follow. It is a set of simple rules and regulations that we obide by. You broke rule number 1, which is a big no no. I see that you are new... Please review our guidelines before posting again. They are at the top of your screen when you post a new topic in bright yellow, and some of the rules are bolded and colored. Please take the time to review and repost your questions according. Thank you.

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

Was This Post Helpful? 0
  • +
  • -

#3 00musdan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 16-November 09

Re: Shopping Program

Posted 16 November 2009 - 06:17 PM

View Posttheautokustomizer, on 16 Nov, 2009 - 05:14 PM, said:

We here at D.I.C. have a policy in which we like to follow. It is a set of simple rules and regulations that we obide by. You broke rule number 1, which is a big no no. I see that you are new... Please review our guidelines before posting again. They are at the top of your screen when you post a new topic in bright yellow, and some of the rules are bolded and colored. Please take the time to review and repost your questions according. Thank you.

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.
Was This Post Helpful? 0
  • +
  • -

#4 theautokustomizer   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 250
  • Joined: 20-September 09

Re: Shopping Program

Posted 16 November 2009 - 06:18 PM

Do you have any of your code started? The reason why I ask, is because the way your instructor wrote these directions, this isn't your first program. You should know how to start the progam, declare your constants and variables, use your import statements and so forth...

This post has been edited by theautokustomizer: 16 November 2009 - 06:22 PM

Was This Post Helpful? 0
  • +
  • -

#5 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Shopping Program

Posted 16 November 2009 - 07:20 PM

Instead of wasting your time trying to use the BBCode to make, unsuccessfully, a nice looking post, you should poke around in this forum looking the thousand of available exemples (may be not with fancy features) but with code... after all we are at Dream In Code
Was This Post Helpful? 0
  • +
  • -

#6 theautokustomizer   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 250
  • Joined: 20-September 09

Re: Shopping Program

Posted 16 November 2009 - 07:50 PM

View Postpbl, on 16 Nov, 2009 - 06:20 PM, said:

Instead of wasting your time trying to use the BBCode to make, unsuccessfully, a nice looking post, you should poke around in this forum looking the thousand of available exemples (may be not with fancy features) but with code... after all we are at Dream In Code


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

Was This Post Helpful? 0
  • +
  • -

#7 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Shopping Program

Posted 16 November 2009 - 08:37 PM

[ /font][ size=7]
Was This Post Helpful? 0
  • +
  • -

#8 theautokustomizer   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 250
  • Joined: 20-September 09

Re: Shopping Program

Posted 16 November 2009 - 08:40 PM

Ahhh, I see, lmao...got ya!
Was This Post Helpful? 0
  • +
  • -

#9 00musdan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 16-November 09

Re: Shopping Program

Posted 16 November 2009 - 09:11 PM

sorry guys im a big noob. heres what i have so far. Thank you for your help ahead of time because a lot of people have done nothing but yell at me for my previous post. This part is for the cash register of the project as outlined above.
 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

Was This Post Helpful? 0
  • +
  • -

#10 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Shopping Program

Posted 16 November 2009 - 10:08 PM

Good you made an effort
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");
		
		
	}
}


Was This Post Helpful? 1

#11 theautokustomizer   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 250
  • Joined: 20-September 09

Re: Shopping Program

Posted 17 November 2009 - 10:06 AM

View Post00musdan, on 16 Nov, 2009 - 08:11 PM, said:

sorry guys im a big noob. heres what i have so far. Thank you for your help ahead of time because a lot of people have done nothing but yell at me for my previous post. This part is for the cash register of the project as outlined above.
 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...
Was This Post Helpful? 0
  • +
  • -

#12 00musdan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 16-November 09

Re: Shopping Program

Posted 17 November 2009 - 12:12 PM

ok thanks pbl i guess this is why ur the master. So i understand the code you wrote but should i make a currency class and declare pennies, nickels, dimes....etc? Because the whole program is supposed to act like a store where people select items and purchase them and the program gives them change, taxes items etc. I guess im just having a hard time planning this whole thing out.
Was This Post Helpful? 0
  • +
  • -

#13 00musdan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 16-November 09

Re: Shopping Program

Posted 17 November 2009 - 01:25 PM

hey guys ok so i tried making a inventory class and a tester class but im getting all kinds of errors that i cant fix. maybe you guys will understand the problem.

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)
Was This Post Helpful? 0
  • +
  • -

#14 theautokustomizer   User is offline

  • D.I.C Regular

Reputation: 16
  • View blog
  • Posts: 250
  • Joined: 20-September 09

Re: Shopping Program

Posted 17 November 2009 - 01:42 PM

I don't see any of your methods for item, and the parameters that you have in your tester go off of them...

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

Was This Post Helpful? 1
  • +
  • -

#15 00musdan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 16-November 09

Re: Shopping Program

Posted 17 November 2009 - 05:01 PM

View Posttheautokustomizer, on 17 Nov, 2009 - 12:42 PM, said:

I don't see any of your methods for item, and the parameters that you have in your tester go off of them...

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

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3