import java.util.Scanner;
class Student //SubClass
{
String stuName,stuBranch,stuRollNo;
int s1,s2,s3,s4,s5,s6,totMarks;
float percentage;
void calculate()
{
totMarks = s1+s2+s3+s4+s5+s6;
percentage = (float)totMarks/6;
}
void getStudent()
{
System.out.println("Student Name:"+stuName);
System.out.println("Student Branch:"+stuBranch);
System.out.println("Student RollNo:"+stuRollNo);
System.out.println("Total Marks:"+totMarks);
System.out.println("percentage:"+percentage);
if (s1>35 && s2>35 && s3>35 && s4>35 && s5>35 &&s6>35)
{
if (percentage>=70)
{
System.out.println("Distinction");
}
if (percentage<70 && percentage>=60 )
{
System.out.println("First");
}
if (percentage<60 && percentage>=50 )
{
System.out.println("Second");
}
if (percentage<50 && percentage>=35 )
{
System.out.println("Third");
}
else
{
System.out.println("....Successfull Records....");
}
}
else
{
System.out.println("...Fail...");
}
}
}
class SMainClass2 //MainClass
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
Student ob = new Student();
System.out.println("Enter the Student Name:");
ob.stuName=s.nextLine();
System.out.println("Enter the Student Branch:");
ob.stuBranch=s.nextLine().toUpperCase();
if(ob.stuBranch.length() == 3)
{
boolean k=false;
switch(ob.stuBranch)
{
case "CSE":k=true;
break;
case "ECE":k=true;
break;
case "EEE":k=true;
break;
}
if(k)
{
System.out.println("Enter the RollNo:");
ob.stuRollNo = s.nextLine();
if(ob.stuRollNo.length()==10)
{
System.out.println("Enter the marks of Sub1:");
ob.s1=s.nextInt();
System.out.println("Enter the marks of Sub2:");
ob.s2=s.nextInt();
System.out.println("Enter the marks of Sub3:");
ob.s3=s.nextInt();
System.out.println("Enter the marks of Sub4:");
ob.s4=s.nextInt();
System.out.println("Enter the marks of Sub5:");
ob.s5=s.nextInt();
System.out.println("Enter the marks of Sub6:");
ob.s6=s.nextInt();
if((ob.s1>=0 && ob.s1<=100)&&(ob.s2>=0 && ob.s2<=100)
&&(ob.s3>=0 && ob.s3<=100)&&(ob.s4>=0 && ob.s4<=100)
&&(ob.s5>=0 && ob.s5<=100)&&(ob.s6>=0 && ob.s6<=100))
{
ob.calculate();
ob.getStudent();
}
else
{
System.out.println("...Invalid Marks...");
}
}
else
{
System.out.println("...Invalid RollNo...");
}
}
else
{
System.out.println("...Branch Not Available...");
}
}
else
{
System.out.println("...Invalid Branch...");
}
}
}
OUTPUT:-
Enter the Student Name:
Amit Kumar
Enter the Student Branch:
eee
Enter the RollNo:
A207123456
Enter the marks of Sub1:
75
Enter the marks of Sub2:
98
Enter the marks of Sub3:
76
Enter the marks of Sub4:
32
Enter the marks of Sub5:
76
Enter the marks of Sub6:
90
----------------------------------------------
Student Name:Amit Kumar
Student Branch:EEE
Student RollNo:A207123456
Total Marks:447
percentage:74.5
...Fail...
0 Comments