i have a problem to do calculation part.
i need to do 3 calculation part.
Now my problem is , my answer for conf and lift loop many times.
may i know how to correct it?
below are my coding:
string b = txtTotalItems.Text;
double e = Double.Parse(b);
double a;
double conf;
double lift;
richTextBox8.Clear();
foreach (double SuppB in list10)
{
richTextBox7.Clear();
foreach (double SuppA in list9)
{
richTextBox9.Clear();
foreach (double wee in list8)
{
a= (wee / e) * 100;
richTextBox9.AppendText(string.Format("{0:n2}", a) + "\n");
conf = a/ (SuppA / e);
richTextBox7.AppendText(string.Format("{0:n2}", conf) + "\n");
lift = conf / (SuppB / e) / 100;
richTextBox8.AppendText(string.Format("{0:n2}", lift) + "\n");
}
}
}
hope anyone can help me..
Loading
VulpesPosted Apr 10, 2011, 10:18 AM
There are the same number of elements in each list and you want to do operations on the corresponding elements of each list.
In that case, you only need one 'for' statement, like this:
y sPosted Apr 10, 2011, 10:05 AM
for example:
in list8, has 3
then a = (3/5)*100
a=60
in list9, has 4
then conf= 60/(4/5)
conf = 75
in list10,has 4
then lift = 75/(4/5)/100
= 0.94
* 5 is mine total transactions.
VulpesPosted Apr 10, 2011, 9:20 AM
If there are, do you only want to calculate values for 'conf' and 'lift' for each value of 'wee' but for only the first value of 'SuppA' and 'SuppB'?
If there are not, do you want to calculate values for 'conf' and 'lift' for each value of 'wee' and as many values of SuppA and SuppB as are necessary to produce list8.Count values altogether?
y sPosted Apr 10, 2011, 8:44 AM
RichTextBox9:
60.00
60.00
60.00
60.00
40.00
60.00
60.00
40.00
40.00
richTextBox 7:
75.00
75.00
75.00
75.00
50.00
75.00
75.00
50.00
50.00
75.00
75.00
75.00
75.00
50.00
75.00
75.00
50.00
50.00
RichTextBox 8:
0.94
0.63
0.94
0.94
0.63
0.63
0.94
0.94
0.94
0.94
0.63
0.94
0.94
0.63
0.63
0.94
0.94
but this not what i wanted.
my expected output is need the 1st nine value in richTExtBox 7 and 8 each.
VulpesPosted Apr 10, 2011, 6:30 AM
y sPosted Apr 10, 2011, 6:16 AM
VulpesPosted Apr 9, 2011, 6:04 PM
y sPosted Apr 9, 2011, 4:51 PM
the attachment that i attached are my complete coding.
y sPosted Apr 9, 2011, 2:05 AM
Suthish NairPosted Apr 9, 2011, 1:58 AM