0
$\begingroup$

I have (n) Packets containing (x) sheets (1 Packet = x Sheet) where (both x and n are integers). Now I want to sale by Packet and By Sheet I created an excel file but I am very confused on how to create an equation.

for example: 4 Packets each containing (5 sheets), total Sheets = 4 * 15 = 20

Case1: I sold 1 Packet and 2 Sheets

Case2: I Sold 1 Sheet Only

Case3: I Sold 1 Packet and 1 Sheets

Balance:

4 Packets - 2 Sold = 2 Packets

(4*5=20) Sheets - 4 Sheets = 16 Sheets

Total Sold = 2 Packets (5 Sheet) + 4 Sheets = 10 + 4 = 14 Sheets It means that (Balance = 20 Sheets - 14 Sheets = 6 Sheets) Only 1 Packet and 1 Sheet remaining.

How to create an equation to update the balance after each transactions?

$\endgroup$

2 Answers 2

1
$\begingroup$

Create two running variables: $p$ storing the number of unopened packets, and $s$ storing the number of left over single sheets. For each intact packet sold decrease $p$ by $1$, for each single sheet sold decrease $s$ by $1$. For each packet opened in order to bring the sheets therein to the fore decrease $p$ by $1$, and increase $s$ by the number $x$ of sheets per packet.

$\endgroup$
0
$\begingroup$

I got these equations and they works fine using excel and MySQL:

Sheet balance = Prev. Balance of sheet - ( (number of packet sold * number of sheet) + (number of sheet sold))

Packet Balance = Prev. Balance of Packet - (number of packets sold) - (if prev. balance of sheet % (modulus) number of sheet in packet >= number of sheets sold, 0,1)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.