TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
amber
NA
39
48k
Using if else condition to compare the result
Oct 26 2013 11:04 AM
Hi,
m calculating the percentage of education expenses with monthly income:
public static decimal per_edu;
int h, i;
public decimal edu_percent()
{
h = Convert.ToInt32(edubox.Text);
i = Convert.ToInt32(inctotal.Text);
per_edu = (h / i) * 100;
return per_edu;
}
Actualy m executing this method on score button it's calculating score and per_edu simultaneously. within a score method, m using per_edu var in an if else condition so is it wrong?? its like ds within a score method:
if (per_edu <= 5)
{
scor7 = Convert.ToInt32(1);
}
else if (per_edu >= (decimal)(5.1) && per_edu <= 10)
{
scor7 = Convert.ToInt32(2);
}
else if (per_edu >= (decimal)(10.1) && per_edu <= 15)
{
scor7 = Convert.ToInt32(3);
}
else if (per_edu >= (decimal)(15.1) && per_edu <= 20)
{
scor7 = Convert.ToInt32(4);
}
else if (per_edu >= (decimal)(20.1))
{
scor7 = Convert.ToInt32(5);
}
textBoxedu.Text = scor7.ToString();
But it's showing only zero for per_edu, i hav checked the datatypes of all var. i couldnt fix it. please anyone guide in this.
Regards,
Reply
Answers (
2
)
IndexOf(x - y)
Socket communication not working over LAN