Hi,
The code m using is:
long eval;
public long Evaluate()
{
k = (scor * 2);
eval = ((k / 100) * 103228);
return eval;
}
on Btn_Evaluate event :
private void button7_Click(object sender, EventArgs e)
{
Evaluate();
MessageBox.Show("Percentage Proposed: " + k + "%" + "\nAmount: " + eval);
}
it shws the eval = 0 everytime i run it but its calculating the percentage proposed "k" correctly.May b m making some silly mistake can anyone help me wd this?? first i click on score btn wich calculates the score and store it in above mentioned "scor" variable then participate in evaluate method is it the right way to do??:
on btn_score:
private void button11_Click(object sender, EventArgs e)
{
score();
if (textBox1.Text != "")
{
MessageBox.Show("The Score is: " + scor);
}
}
Thanx in advance
Loading

VulpesRank #55 · 29.2K reputationPosted Oct 20, 2013, 1:28 PM EDT
eval = ((k / 100) * 103228);
with this:
eval = (long)((k / 100.0) * 103228);
Jignesh TrivediRank #16 · 50.3K reputationPosted Oct 20, 2013, 8:51 PM EDT
what is datatype and value of "scor" variable?
amber34 reputationPosted Oct 25, 2013, 12:01 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 25, 2013, 1:05 PM EDT
By using 100.0 instead of 100, we force floating point arithmetic (double type) to be used instead but we then need to cast back to long again when the calculation is completed.
amber34 reputationPosted Oct 26, 2013, 7:13 AM EDT