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

VulpesRank #55 · 29.2K reputationPosted Apr 10, 2011, 6:18 AM EDT
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:
Suthish NairRank #92 · 22.8K reputationPosted Apr 8, 2011, 9:58 PM EDT
y s62 reputationPosted Apr 8, 2011, 10:05 PM EDT
y s62 reputationPosted Apr 9, 2011, 12:51 PM EDT
the attachment that i attached are my complete coding.
VulpesRank #55 · 29.2K reputationPosted Apr 9, 2011, 2:04 PM EDT
y s62 reputationPosted Apr 10, 2011, 2:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 10, 2011, 2:30 AM EDT
y s62 reputationPosted Apr 10, 2011, 4:44 AM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Apr 10, 2011, 5:20 AM EDT
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 s62 reputationPosted Apr 10, 2011, 6:05 AM EDT
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.