import java.util.Scanner;
class Student
{
int rollNo;
String name;
int marks1, marks2, marks3;
int total;
double percentage;
String grade;
void input(Scanner sc)
{
System.out.print("Enter Roll Number: ");
rollNo = sc.nextInt();
sc.nextLine();
System.out.print("Enter Student Name: ");
name = sc.nextLine();
System.out.print("Enter Marks in Subject 1: ");
marks1 = sc.nextInt();
System.out.print("Enter Marks in Subject 2: ");
marks2 = sc.nextInt();
System.out.print("Enter Marks in Subject 3: ");
marks3 = sc.nextInt();
calculate();
}
void calculate()
{
total = marks1 + marks2 + marks3;
percentage = total / 3.0;
if(percentage >= 90)
grade = "A+";
else if(percentage >= 80)
grade = "A";
else if(percentage >= 70)
grade = "B";
else if(percentage >= 60)
grade = "C";
else if(percentage >= 40)
grade = "D";
else
grade = "F";
}
void display()
{
System.out.println("--------------------------------");
System.out.println("Roll Number : " + rollNo);
System.out.println("Name : " + name);
System.out.println("Subject 1 : " + marks1);
System.out.println("Subject 2 : " + marks2);
System.out.println("Subject 3 : " + marks3);
System.out.println("Total Marks : " + total);
System.out.println("Percentage : " + percentage + "%");
System.out.println("Grade : " + grade);
System.out.println("--------------------------------");
}
}
public class StudentManagement
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Student s[] = new Student[50];
int choice;
int count = 0;
int i, searchRoll;
boolean found;
do
{
System.out.println("\n================================");
System.out.println(" STUDENT MANAGEMENT SYSTEM");
System.out.println("================================");
System.out.println("1. Add Student Record");
System.out.println("2. Display All Students");
System.out.println("3. Search Student");
System.out.println("4. Display Topper");
System.out.println("5. Display Class Average");
System.out.println("6. Display Failed Students");
System.out.println("7. Exit");
System.out.println("================================");
System.out.print("Enter Your Choice: ");
choice = sc.nextInt();
switch(choice)
{
case 1:
if(count < 50)
{
s[count] = new Student();
System.out.println("\nEnter Student Details:");
s[count].input(sc);
count++;
System.out.println("\nRecord Added Successfully!");
}
else
{
System.out.println("Student Limit Reached!");
}
break;
case 2:
if(count == 0)
{
System.out.println("No Records Available!");
}
else
{
System.out.println("\nALL STUDENT RECORDS");
for(i = 0; i < count; i++)
{
s[i].display();
}
}
break;
case 3:
System.out.print("Enter Roll Number to Search: ");
searchRoll = sc.nextInt();
found = false;
for(i = 0; i < count; i++)
{
if(s[i].rollNo == searchRoll)
{
System.out.println("\nStudent Found!");
s[i].display();
found = true;
break;
}
}
if(found == false)
{
System.out.println("Student Record Not Found!");
}
break;
case 4:
if(count == 0)
{
System.out.println("No Student Records Available!");
}
else
{
int max = 0;
for(i = 1; i < count; i++)
{
if(s[i].total > s[max].total)
{
max = i;
}
}
System.out.println("\nCLASS TOPPER");
s[max].display();
}
break;
case 5:
if(count == 0)
{
System.out.println("No Records Available!");
}
else
{
double sum = 0;
for(i = 0; i < count; i++)
{
sum = sum + s[i].percentage;
}
System.out.println("Class Average: " +
(sum / count) + "%");
}
break;
case 6:
found = false;
System.out.println("\nFAILED STUDENTS");
for(i = 0; i < count; i++)
{
if(s[i].percentage < 40)
{
s[i].display();
found = true;
}
}
if(found == false)
{
System.out.println("No Failed Students!");
}
break;
case 7:
System.out.println("\nThank You!");
System.out.println("Program Terminated.");
break;
default:
System.out.println("Invalid Choice! Try Again.");
}
}while(choice != 7);
sc.close();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: