public void CalculateTotal()
{
int th1, th2, practical, oral, termwork, total;
double percentage;
th1 = Convert.ToInt32(txtTheory1.Text);
th2 = Convert.ToInt32(txtTheory2.Text);
practical = Convert.ToInt32(txtPractical.Text);
oral = Convert.ToInt32(txtOral.Text);
termwork = Convert.ToInt32(txtTermWork.Text);
total = th1 + th2 + practical + oral + termwork;
txtTotal.Text = total.ToString();
if (Convert.ToInt32(txtTheory2.Text) == 0)
{
percentage = total * 100 f / 300;
txtPercent.Text = Math.Round(percentage, 2).ToString() + " %";
}
}Code to display Percentage in 2 decimal Values.
