Republic of the Philippines
Tarlac State University
College of Computer Studies
SY: 2010-2011
CASE STUDY
PROG3 JAVA
Submitted by:
Zablan, Ronnel
Vicente, Donna Belle V.
Estanislao, Mayflor O.
Tañedo, Melchor
BSIT-2A
Submitted to:
Prof. Jeffrey Tolentino
import java.io.*;
import java.util.*;
import java.lang.*;
class Student {
public static void main (String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedReader in = new BufferedReader(new FileReader("Subject.txt"));
BufferedReader in1 = new BufferedReader(new FileReader("StudentProfile.txt"));
BufferedReader in2 = new BufferedReader(new FileReader("Student.txt"));
String[] subjectList = new String[100];
String ans,choice,studno,read,subject,profile,student;
int choiceNum;
FileWriter subjfw = new FileWriter("Subject.txt");
FileWriter studfw = new FileWriter("Student.txt");
FileWriter studsubjfw = new FileWriter("StudentProfile.txt");
do {
System.out.println("\n\n\n\n\nPlease select from the choices");
System.out.println(" 1 - Register a Subject ");
System.out.println(" 2 - Register a Student ");
System.out.println(" 3 - Add Subject for Student ");
System.out.println(" 4 - View Student Profile ");
System.out.println(" 5 - Exit \n");
System.out.print("Your choice is: ");
choice = br.readLine();
choiceNum = Integer.parseInt(choice);
try {
if (choiceNum == 1) {
do {
System.out.println("\n\nEnter Subject/s: ");
subjfw.write(br.readLine());
subjfw.write("\r\n");
System.out.println("Enter again? (y/n): ");
ans = br.readLine();
} while (ans.charAt(0) == 'y' || ans.charAt(0) == 'Y');
subjfw.flush();
}
else if (choiceNum == 2) {
do {
System.out.println("\n\nEnter Student No.: ");
studfw.write(br.readLine());
System.out.println("\nEnter Student Name: ");
studfw.write(br.readLine());
studfw.write("\r\n");
System.out.println("Enter again? (y/n): ");
ans = br.readLine();
} while (ans.charAt(0) == 'y' || ans.charAt(0) == 'Y');
studfw.flush();
}
else if (choiceNum == 3) {
System.out.println("Subject Offered");
while ((subject = in.readLine()) != null) {
System.out.println(subject);
}
in.close();
System.out.println("\n\nEnter Student No.: ");
studno = br.readLine();
do {
System.out.println("\nEnter Subjects to be enrolled: ");
studsubjfw.write(studno);
studsubjfw.write(br.readLine());
studsubjfw.write("\r\n");
System.out.println("Enter again? (y/n): ");
ans = br.readLine();
} while (ans.charAt(0) == 'y' || ans.charAt(0) == 'Y');
studsubjfw.flush();
}
else if (choiceNum == 4) {
do {
System.out.println("\n\nEnter Student No.: ");
studno = br.readLine();
System.out.println("Student's Name:");
while ((student = in2.readLine()) != null) {
if (student.charAt(0) == studno.charAt(0)) {
for (int i = 1; i <= student.length()-1; i++) {
System.out.print(student.charAt(i));
}
}
}
in2.close();
System.out.println("Student's Subject/s:");
while ((profile = in1.readLine()) != null) {
if (profile.charAt(0) == studno.charAt(0)) {
for (int i = 1; i <= profile.length()-1; i++) {
System.out.print(profile.charAt(i));
}
System.out.println();
}
}
in1.close();
System.out.println("Enter again? (y/n): ");
ans = br.readLine();
} while (ans.charAt(0) == 'y' || ans.charAt(0) == 'Y');
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
} while (choice.charAt(0) != '5')
}
Description
Republic of the Philippines
Tarlac State University
College of Computer Studies
SY: 2010-2011
CASE STUDY
PROG3 JAVA
Submitted by:
Zablan, Ronnel
Vicente, Donna Belle V.
Estanislao, Mayflor O.
Tañedo, Melchor
System.out.println("\n\n\n\n\nPlease select from the choices");
System.out.println(" 1 - Register a Subject ");
System.out.println(" 2 - Register a Student ");
System.out.println(" 3 - Add Subject for Student ");
System.out.println(" 4 - View Student Profile ");
System.out.println(" 5 - Exit \n");
System.out.print("Your choice is: ");
choice = br.readLine();
choiceNum = Integer.parseInt(choice);
Presentation Transcript
Your Facebook Friends on WizIQ