kit kat - 4 months ago 16

C# Question

I have a problem with some calculation regarding how to divide such amount into dynamic parameter. Let I show the 2 scenario below:-

I have dynamic label like XT and XO where XO should be half from XT after amount a divide.

`Scenario 1:`

Amount = 200

XT = 100

XT = 100

Scenario 2:

Amount = 200

XO = 50

XO = 50

XT = 100

This label XO and XT are dynamic where can be add more or delete, than I need do recalculation again.

Please help me regarding this matter either on .net or javascript.

Answer

I think you need this small logical to do that, the rest you should do you self.

Let me show my syntax on javascript what I know:-

```
ttrans = (Number(tfull) * 2) + (Number(thalf) * 1);
dfamt = Number(damt) / Number(ttrans)*2;
dhamt = Number(dfamt) / 2;
```

Let me explain what are variable stand for

- tfull is your total count XT, u need to count how many XT are appear
thalf is your total count XO

ttrans is total (XT*2) + (X0*1) - u need that

- dfamt is amount should be assign to XT
- dhamt is amount should be assign to XO

That all for the calculation and assign each value even your XT or XO are dynamic OR your amount are change this syntax above will help you re-calculate.