Course Management System

 import java.util.InputMismatchException;

import java.util.Scanner;
// Author : Abhinav
public class CourseSystem extends Log{

public static void main(String[] args) {
CourseSystem ob = new CourseSystem();
Scanner in = new Scanner(System.in);
ob.logging();

}
}

class Admin_Feature{
Scanner in=new Scanner(System.in);
void add_student(){
System.out.println("Enter name of Student");
String name_student=in.nextLine();
System.out.println("Enter Roll No of Student");
long roll_no=in.nextLong();
}
void add_Course(){
System.out.println("Enter name of Course");
String name_student=in.nextLine();
System.out.println("Enter Teacher Name");
String name_teacher=in.next();
}


}
class Student_Feature {

}
class Course_Management{

}

class Student_Information{
String[] strname ;
String[] strpass;
protected Student_Information() {
strname=new String[10];
strpass=new String[10];
strname[0]="Abhinav";
strname[1]="Mohit";
strname[2]="Sangeeta";
strname[3]="Mayur";
strname[4]="Prashant";
strpass[0]="0000";
strpass[1]="0000";
strpass[2]="0000";
strpass[3]="0000";
strpass[4]="0000";
}

}
class Admin_Information{
String[] admin_name;
String[] admin_pass;
Admin_Information(){
admin_name=new String[10];
admin_pass=new String[10];
}
void Admin_info(){
admin_name[0]="Abhi";
admin_pass[0]="qwerty";

}
}
class Log extends Student_Information{
Scanner in = new Scanner(System.in);
String name;
String password;
int space,n;
Log() {
name = "";
password = "";
space=check(strname)-1;
}
void log(){
System.out.println("Enter Name ");
name = in.next();
System.out.println("Enter Password");
password = in.next();
if (check_log()) {
System.out.println("User Available");
System.out.println("Test Pass");
} else
System.out.println("User Does Not Exist");
}
int check(String arr[])
{
int count=0;
for (int i = 0; i <arr.length; i++) {
if(arr[i]!=null)
count++;

}
return count;
}
// condition area
boolean binary_search(String[] arr, String search) {
int l = 0;

while (l <= space) {
int mid = (l + space) / 2;
if (arr[mid].equals(search))
{
return true;
}
// if search element is smaller than middle element
if (arr[mid].compareTo(search) > 0) {
space = mid - 1;
} else
l = mid + 1;

}
return false;
}

//Checking logging information
boolean check_log() {
if (binary_search(strname, name)) {
if (binary_search(strpass, password)) {
return true;
}
}
return false;
}
void logging(){
System.out.println("Welcome To Course Management System");
try{
System.out.println("Space Available "+space);
System.out.println("Press 1 for Admin Login \n Press 2 for Student login");
int choice = in.nextInt();
switch (choice) {
case 1:
System.out.println("\tAdmin Login");
log();
break;
case 2:
System.out.println("\tStudent Login");
log();
break;
}
}
catch (InputMismatchException e){
System.out.println("Please Enter 1 and 2");

}
}


}

Comments