0% found this document useful (0 votes)
12 views4 pages

Code SA BSIT

The document is a Java program for a school management system that allows users to log in as teachers or students. Once logged in, users can view and manage lists of teachers and students, as well as subjects offered. The program includes options for adding new teachers and students, and provides a simple menu interface for navigation.

Uploaded by

carllorenz310
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Code SA BSIT

The document is a Java program for a school management system that allows users to log in as teachers or students. Once logged in, users can view and manage lists of teachers and students, as well as subjects offered. The program includes options for adding new teachers and students, and provides a simple menu interface for navigation.

Uploaded by

carllorenz310
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

import java.util.

Scanner;
import java.util.ArrayList;

class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

System.out.println("----------------------------SCHOOL
PROGRAM----------------------------");

ArrayList<String> teach = new ArrayList<String>();


teach.add("Mr. Aizen");
teach.add("Mrs. Roberts");
teach.add("Ms. Davis");
teach.add("Dr. Clark");

ArrayList<String> students = new ArrayList<String>();


students.add("John Doe");
students.add("Jane Smith");
students.add("Alice Johnson");
students.add("Bob Brown");

String[] usernames = {"teacher", "student", "admin"};


String[] passwords = {"1234", "abcd", "admin"};

String[] subjects = {"Computer Programming", "Introduction to Computing",


"Physical Education", "Computer Programming 2"};

boolean continueProgram = true;

while (continueProgram) {
System.out.println("[1] Login....");
System.out.println("[2] Exit.....");
System.out.print("Enter Number: ");

if (!sc.hasNextInt()) {
System.out.println("Invalid input. Please enter a number.");
sc.next();
continue;
}

int choice = sc.nextInt();


sc.nextLine();

if (choice == 1) {

System.out.println("---------------------------------------------------------------
");
System.out.print("Enter Username: ");
String username = sc.nextLine();
System.out.print("Enter Password: ");
String password = sc.nextLine();

boolean validLogin = false;

for (int i = 0; i < usernames.length; i++) {


if (usernames[i].equals(username) &&
passwords[i].equals(password)) {
validLogin = true;
if (i == 0) {
System.out.println("--------Welcome Teacher---------");
} else {
System.out.println("--------Welcome Student---------");
}
break;
}
}

if (!validLogin) {
System.out.println("Invalid username or password");
continue;
}

boolean menuActive = true;


while (menuActive) {
System.out.println("--------[1] Teachers---------");
System.out.println("--------[2] Students--------");
System.out.println("--------[3] Subjects----------");
System.out.println("--------[4] Tuition Fee--------------");
System.out.println("--------[5] Exit--------------");

System.out.print("Enter Number: ");


if (!sc.hasNextInt()) {
System.out.println("Invalid input. Please enter a valid
number.");
sc.next();
continue;
}

int menuChoice = sc.nextInt();


sc.nextLine();

switch (menuChoice) {
case 1:

System.out.println("----------------------------
TEACHERS----------------------------");
for (String teacher : teach) {
System.out.println(teacher);
}

System.out.println("Do you want to add a new teacher?


[yes/no]");
String addTeacherChoice = sc.nextLine();
if (addTeacherChoice.equalsIgnoreCase("yes")) {
System.out.print("Enter the new teacher's name: ");
String newTeacher = sc.nextLine();

teach.add(newTeacher);
System.out.println("New teacher added
successfully!");
}
System.out.println("---------------------------------------------------------------
");
break;

case 2:

System.out.println("----------------------------
STUDENTS----------------------------");
for (String student : students) {
System.out.println(student);
}

System.out.println("Do you want to add a new student?


[yes/no]");
String addStudentChoice = sc.nextLine();
if (addStudentChoice.equalsIgnoreCase("yes")) {
System.out.print("Enter the new student's name: ");
String newStudent = sc.nextLine();
students.add(newStudent);
System.out.println("New student added
successfully!");
}

System.out.println("---------------------------------------------------------------
");
break;

case 3:

System.out.println("----------------------------
SUBJECTS----------------------------");
for (String subject : subjects) {
System.out.println(subject);
}

System.out.println("---------------------------------------------------");
break;

case 4:

System.out.println("Tuition Fee feature coming


soon...");
break;

case 5:

System.out.println("Exiting program...");
menuActive = false;
break;

default:
System.out.println("Invalid choice");
break;
}
}
} else if (choice == 2) {
System.out.println("Exiting program...");
continueProgram = false;
} else {
System.out.println("Invalid choice. Please try again.");
}
}
}
}

You might also like