Results 1 to 14 of 14
- 03-15-2012, 11:39 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 18
- Rep Power
- 0
Trying to create a running total.
I have been writing an application for a Point of Sale system. It's based on a grocery store idea. So far, i have been doing pretty well, but i have not been able to figure out this last problem.
When i print My Invoice i also want to show a running total of sales for that day.
I have already been able to get the total for one transaction, but i can't seem to think about how i would create the total for several transactions and show it on each receipt.
Any Help would be great!
You can find my Source Code here.
https://github.com/Skybeorn/Discount...ountstrategyme
- 03-16-2012, 12:43 AM #2
Re: Trying to create a running total.
Can you show what the program currently prints out and explain how you want to change ithow i would create the total for several transactions and show it on each receipt.
If you have questions about your code, please post it here on the forum.
- 03-16-2012, 03:53 PM #3
Member
- Join Date
- Mar 2012
- Posts
- 18
- Rep Power
- 0
Re: Trying to create a running total.
Output as is...
101
Jane Doe
ID Name Qty Cost Discount Total
================================================== ===============
1 Milk 8.0 15.0 30.0 90.0
2 Juice 10.0 10.0 50.0 50.0
3 Tea 25.0 5.0 0.0 125.0
==================================
Total Owned: 265.0
Total Saved: 80.0
Trying to get it like this.
102
John Doe
ID Name Qty Cost Discount Total
================================================== ===============
1 Milk 8.0 15.0 30.0 90.0
2 Juice 10.0 10.0 50.0 50.0
3 Tea 25.0 5.0 0.0 125.0
==================================
Total Owned: 265.0
Total Saved: 80.0
==================================
Total Saved for day: 160.0
Total Sales: 530.0
Does that make sense? I having trouble thinking of how to store the Total Sales and Discounts.
- 03-16-2012, 03:57 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Re: Trying to create a running total.
If this is a simple standalone program, then a simple static hashmap, if it is a web/enterprise application, then an attributes in the application context or a persistent bean.
Edit: And, of course, you always have the option of using files or a db to store the "running" totals.
- 03-16-2012, 04:53 PM #5
Member
- Join Date
- Mar 2012
- Posts
- 18
- Rep Power
- 0
Re: Trying to create a running total.
Never done a hash map before...
Or file writing, or used a DB. I know that sounds funny. Need i post my code?
- 03-16-2012, 04:56 PM #6
Re: Trying to create a running total.
I don't thick you need any of those if the program has all the data it needs to generate the report. You would only need those things if you wanted to save the data for more than one execution of the program. Say from one day to rhe next.
- 03-16-2012, 05:04 PM #7
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Re: Trying to create a running total.
He Seems, from the Sample Output, to at least Need it from Order to Order. So, no, judging by that it is Not all in the Same "Session".
- 03-16-2012, 05:05 PM #8
Re: Trying to create a running total.
The OP will have to determine how his code is to work depending on ...
- 03-16-2012, 06:12 PM #9
Member
- Join Date
- Mar 2012
- Posts
- 18
- Rep Power
- 0
Re: Trying to create a running total.
One Customer comes in and buys whatever items they need.
The application finds the items in a DB(Since i don't have a DB i'm using an array with just a couple items), looks to see if they have a Discount strategy and then applies that discount.
Then the app totals the sale amount up, and the discount and prints it out to the console, showing the output you see from Jane Doe.
That is one session.
The next session:
Then John Doe comes in and buys whatever he needs. The app does the same thing again.
What i am trying to do is take Jane's and John's Total discount and total bill, add them together and show the Running Total in Sales and Discount for that store.
- 03-16-2012, 06:16 PM #10
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Re: Trying to create a running total.
Then a Single Set of additional variables is all you need.
- 03-16-2012, 06:17 PM #11
Re: Trying to create a running total.
What do you mean by a session? Is that a different execution of the program, maybe on different days?
- 03-16-2012, 06:21 PM #12
Member
- Join Date
- Mar 2012
- Posts
- 18
- Rep Power
- 0
Re: Trying to create a running total.
When I said Session, I just mean one transaction, or one customer buying something.
- 03-16-2012, 06:25 PM #13
Member
- Join Date
- Mar 2012
- Posts
- 18
- Rep Power
- 0
- 03-16-2012, 07:27 PM #14
Similar Threads
-
Create Table to Add Total
By savio21 in forum New To JavaReplies: 2Last Post: 11-30-2011, 03:58 PM -
Keeping track of running total help
By masterasia in forum JCreatorReplies: 1Last Post: 03-25-2011, 07:26 AM -
Running total little help
By silverspoon34 in forum Forum LobbyReplies: 9Last Post: 02-27-2011, 09:19 PM -
SQLite database wont create during web app running but will when run as main
By teckygamer in forum JDBCReplies: 12Last Post: 08-26-2010, 10:14 AM -
Running Total by Key Group in HashMap
By KevMull in forum New To JavaReplies: 3Last Post: 11-16-2009, 03:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks