There are three functions in this program called add(), per() and Grade(). add() function will take marks as parameters and per() function will calculate percentage of given marks. while grade() will evaluate grade on the basis of percentage.
class markproject
{
int h,e,p,c,m,totmark,percentage;
int add(int h,int e,int p,int c,int m)
{
totmark = h+e+c+p+m;
return totmark;
}
void per()
{
percentage = totmark/5;
}
void grade()
{
if (percentage>=45 && percentage<60)
{
System.out.println("Grade is C");
}
if (percentage>=60 && percentage<=80)
{
System.out.println("Grade is a");
}
if (percentage>=80 && percentage<=100)
{
System.out.println("Grade is a+");
}
}
};
class mark
{
public static void main(String[] args)
{
markproject mp1;
mp1 = new markproject();
int totmark=mp1.add(55,65,75,85,95);
System.out.println(totmark);
mp1.per();
System.out.println(mp1.percentage);
mp1.grade();
}
}
No comments:
Post a Comment