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
VulpesPosted Oct 20, 2013, 5:28 PM
eval = ((k / 100) * 103228);
with this:
eval = (long)((k / 100.0) * 103228);
amberPosted Oct 26, 2013, 11:13 AM
VulpesPosted Oct 25, 2013, 5:05 PM
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.
amberPosted Oct 25, 2013, 4:01 PM
Jignesh TrivediPosted Oct 21, 2013, 12:51 AM
what is datatype and value of "scor" variable?