Student Information System Print PDF
Student Information System Print PDF
Bahawalpur
}
public void display() {
}
}
Inherited from Person class “Student” class:
import java.util.Scanner;
public class Student extends Person {
Scanner scanner = new Scanner(System.in);
public void inputData() {
System.out.print("Entre Name: ");
String name = scanner.nextLine();
setName(name);
System.out.print("Entre Father Name: ");
String Fname = scanner.nextLine();
setFName(Fname);
System.out.print("Entre Age: ");
int age = scanner.nextInt();
setAge(age);
System.out.print("Entre Address: ");
String Addr = scanner.nextLine();
setAddress(Addr);
scanner.nextLine();
}
public void display() {
System.out.println("-------------------------");
System.out.println("Name: "+ getName());
System.out.println("Father Name: "+ getFName());
System.out.println("Age: "+ getAge());
System.out.println("Address: "+ getAddress());
System.out.println("-------------------------");
}
}
Main Class “Control”:
import java.util.*;
public class Control {
private static final String ID = "Sufian";
private static final String PASSWORD = "Sufian123";
private static boolean Validation(String EnterdID, String EnteredPassword) {
if(ID.equals(EnterdID) && PASSWORD.equals(EnteredPassword)) {
return true;
}
else {
return false;
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String repeat;
int repeatDisplay;
System.out.println("Welcome to the Student Information System");
System.out.print("Enter ID: ");
String EnterID = scanner.nextLine();
System.out.print("Enter password: ");
String EnterPassword = scanner.nextLine();
if (Validation(EnterID, EnterPassword)) {
System.out.println("Login successful. Welcome, " + EnterID + "!");
do {
System.out.print("To Start Enter 'Start': ");
String start = scanner.nextLine();
if(start.equalsIgnoreCase("Start")) {
System.out.print("To Entre data press '1': ");
int enter = scanner.nextInt();
System.out.print("Entre Number of Students in your class: ");
int S = scanner.nextInt();
scanner.nextLine();
Person[] S1 = new Person[S];
if(enter == 1) {
for(int i= 0; i< S1.length; ++i) {
S1[i] = new Student();
int a = i+1;
System.out.println("Roll no: “+ a);
S1[i].inputData();
}
do {
System.out.print("To display All Students data press '1'"
+ "\nTo Press '2' to Display with Roll no"
+ "\nPress '3' to Correct Data: ");
int Display = scanner.nextInt();
if(Display == 1) {
for(int i= 0; i< S1.length; ++i) {
S1[i].display();
}
}
else if(Display == 2) {
System.out.print("Entre roll no: ");
int r = scanner.nextInt();
if(r>=1 && r<= S1.length) {
S1[--r].display();
}
}
else if(Display == 3) {
System.out.print("Entre roll no: ");
int c = scanner.nextInt();
if(c>=0 && c<= S1.length) {
S1[--c].inputData();
}
else
System.out.println("Invalid Roll no");
}
System.out.print("Press '0' to Proseed
Further "
+ "Press '1' to Display again: ");
repeatDisplay = scanner.nextInt();
scanner.nextLine();
}
while(repeatDisplay == 1);
}
}
else {
System.out.println("Invalid Command");
}
System.out.print("If you want to Exit Press Yes --> 'Y'"
+ "\n OR To Start over Press No --> 'N': ");
repeat = scanner.nextLine();
scanner.nextLine();
}while(repeat.equalsIgnoreCase("N"));
}
else {
System.out.println("Invalid username or password. Please try again.");
}
scanner.close();
}
}
Explanation:
Our program consists of 3 classes named “Person”, “Student” and main Class “Control”.
Person:
“Person” class is the parent class from which “Student” class is inherited We put Dummy
methods named “inputData” and “display”. Marked the properties as “Protected” as we call
these properties in Student class so its important for us to mark them as “protected”.
Student:
After that in Student class, we place input and Display methods named “inputData” and
“display” respectively.
Control:
After that in main class “Control” we use some static methods in that we use in Log in process
after that we enter no of students from user and set the in Object, we created with Array which
set no of students (Objects).
UML Diagram: