Upload
spiderpratik
View
225
Download
0
Embed Size (px)
Citation preview
8/14/2019 Full Cta Proj
1/36
import java.io.*;import PROJECT_FILES.*;
public class project extends read implements Runnable{
private String pass;
public project() throws IOException
{try{
BufferedReader fr = new BufferedReader(new FileReader("pass.passx"));pass = fr.readLine();fr.close();
}catch (FileNotFoundException e){
PrintWriter pw = new PrintWriter(new FileWriter("pass.passx", true));pw.println("password");pw.close();pass = "password";
File tmp = new File("pass.passx");tmp.setReadOnly();
}}
private project(String tmp){}
public static void main(String args[]) throws IOException{
main();}
public static void main() throws IOException{
Sopln("Sharada Mandir Term 1 Report");Sopln("\nNote: DO NOT CLOSE the applet windows that open by clicking the
cross on the top.\nIf you close it this PROGRAM WILL STOP.\nClick the close buttonto close it.\n");
project proj = new project();Thread tmpthread = new Thread(new project(""), "text");applets.Title.thread(tmpthread);tmpthread.start();lines(2);proj.password();
proj.validate();proj.main_menu();
}
public void run(){
new applets.Title().main();}
private void password() throws IOException{
8/14/2019 Full Cta Proj
2/36
password.pass(pass);}
private void validate(){
password.validate();}
public void main_menu() throws IOException{
File tmp = new File("PROJECT_FILES/report.dat");while (tmp.exists()){
Sopln("\n\n\tMain Menu");switch(menu("Add a record--Search for a record--Edit an entry--Delete
record(s)--Disply All records--Change Password--Save changes and log out", "--")){
case 1 : lines(2); add(); break;case 2 : lines(2); search(); break;case 3 : lines(2); edit(); break;case 4 : lines(2); delete(); break;
case 5 : lines(2); dispall(); break;case 6 : lines(2); change_pass('n'); break;case 7 : lines(2); exit("Log Out Successful.\nThank You.");default : lines(2); Sopln("\nPlease enter a valid choice");
lines(2);}
}while (!tmp.exists()){
Sopln("\n\n\tMain Menu");switch(menu("Add a record--Change Password--Save changes and log out",
"--")){
case 1 : lines(2); add(); break;case 2 : lines (2); change_pass('n'); break;case 3 : lines (2); exit("Thank You");default : lines(2); Sopln("\nPlease enter a valid choice");
lines(2);}
}main_menu();
}
private void add() throws IOException{
new add().main();
}
private void edit() throws IOException{
new edit().main();}
private void delete() throws IOException{
new delete().main();}
8/14/2019 Full Cta Proj
3/36
private void search() throws IOException{
new search().main();}
private void change_pass(char error_var) throws IOException{
new change_pass().change_pass(error_var, pass);}
private void dispall() throws IOException{
String[] rec = no_of_lines.records();Sopln("perm_no\t\tclass\t\troll_no\t\tname");for (int i = 0; i < rec.length; i++){
String[] tmp = rec[i].split("-");int t = 0;Sopln(tmp[t++] + "\t\t10" + tmp[t++] + "\t\t" + tmp[t++] + "\t\t" +
tmp[t]);
}}
}
8/14/2019 Full Cta Proj
4/36
import java.io.File;import PROJECT_FILES.read;
public class clear{
static void main(){
report_only();pass_only();
}
static void report_only(){
File f2 = new File("PROJECT_FILES/report.dat");read.Sopln((f2.exists() ? f2.delete() : "null") + "
PROJECT_FILES/report.dat");
}
static void pass_only(){
File f1 = new File("pass.passx");read.Sopln((f1.exists() ? f1.delete() : "null") + " pass.passx");
}}
8/14/2019 Full Cta Proj
5/36
package PROJECT_FILES;import java.io.*;
public class read{
public static BufferedReader br = new BufferedReader(newInputStreamReader(System.in));
public static char rChar(){
try{
return (char) br.read();}catch (IOException xyz){
return ' ';}catch (StringIndexOutOfBoundsException e){
Sopln("Wrong Entry");return rChar();
}}
public static char rChar2(){
try{
return br.readLine().charAt(0);}catch (IOException xyz){
return ' ';}catch (StringIndexOutOfBoundsException e)
{Sopln("Wrong Entry");return rChar();}}
public static String rString(){
try{
return br.readLine();}catch (IOException xyz){
return "";}
}
8/14/2019 Full Cta Proj
6/36
public static int rInt(){
try{
return Integer.parseInt(br.readLine());}catch (IOException xyz)
{return 0;
}catch (NumberFormatException xyz1){
System.out.println("Wrong Entry");return rInt();
}}
public static double rDouble(){
try
{return Double.parseDouble(br.readLine());
}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println("Wrong Entry");return rDouble();
}}
public static float rFloat(){
try{
return Float.parseFloat(br.readLine());}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println("Wrong Entry");return rFloat();
}}
public static byte rByte(){
try{
return Byte.parseByte(br.readLine());}
8/14/2019 Full Cta Proj
7/36
catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println("Wrong Entry");return rByte();
}}
public static short rShort(){
try{
return Short.parseShort(br.readLine());}catch (IOException xyz){
return 0;}
catch (NumberFormatException xyz1){
System.out.println("Wrong Entry");return rShort();
}}
public static long rLong(){
try{
return Long.parseLong(br.readLine());}
catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println("Wrong Entry");return rLong();
}}
public static void lines(int x){
for (int i = 0; i < x; i++)System.out.println();
}
public static void spaces(int x){for (int i = 0; i < x; i++)System.out.print(' ');
}
public static void Sopln(long s)
8/14/2019 Full Cta Proj
8/36
{System.out.println(s);
}
public static void Sopln(String s){System.out.println(s);
}
public static void Sopln(char s){System.out.println(s);
}
public static void Sopln(boolean s){System.out.println(s);
}
public static void Sopln(){
System.out.println();}
public static void Sop(long s){System.out.print(s);
}
public static void Sop(String s){System.out.print(s);
}
public static void Sop(char s){System.out.print(s);
}
public static void Sop(boolean s){System.out.print(s);
}
public static void Sop(){System.out.print("");
}
public static void exit(){System.exit(0);
}
public static void Sopln(double d){System.out.println(d);
}
8/14/2019 Full Cta Proj
9/36
public static void Sop(double d){System.out.print(d);
}
public static String toString(long n){
return "" + n;}
public static String toString(double n){return "" + n;
}
public static String toString(char n){return "" + n;
}
public static char rChar(String s){
try{
return (char) br.read();}catch (IOException xyz){
return ' ';}catch (StringIndexOutOfBoundsException e){
Sopln(s);
return rChar(s);}
}
public static char rChar2(String s){try{
return br.readLine().charAt(0);}catch (IOException xyz){
return ' ';
}catch(StringIndexOutOfBoundsException e){
return rChar2(s);}catch(NullPointerException e){return rChar2(s);
}}}
8/14/2019 Full Cta Proj
10/36
public static int rInt(String s){
try{
return Integer.parseInt(br.readLine());}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println(s);return rInt(s);
}}
public static double rDouble(String s){
try{
return Double.parseDouble(br.readLine());}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println(s);return rDouble(s);
}}
public static float rFloat(String s){
try{
return Float.parseFloat(br.readLine());}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println(s);
return rFloat(s);}
}
public static String toTitleCase(String str){
char[] ch = str.toLowerCase().toCharArray();if (ch.length != 0)
ch[0] = Character.toUpperCase(ch[0]);for (int i = 1; i < str.length(); i++)
if (ch[i - 1] == ' ')
8/14/2019 Full Cta Proj
11/36
ch[i] = Character.toUpperCase(ch[i]);return new String(ch);
}
public static byte rByte(String s){
try{
return Byte.parseByte(br.readLine());}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println(s);return rByte(s);
}}
public static short rShort(String s){
try{
return Short.parseShort(br.readLine());}catch (IOException xyz){
return 0;}catch (NumberFormatException xyz1){
System.out.println(s);
return rShort(s);}
}
public static void clrStream(){
try{
br.readLine();}catch (IOException e){}
}
public static long rLong(String s){try{
return Long.parseLong(br.readLine());}catch (IOException xyz){
return 0;}
8/14/2019 Full Cta Proj
12/36
catch (NumberFormatException xyz1){
System.out.println(s);return rLong(s);
}}
public static double round(double no, int places_after_decimal)
{no *= Math.pow(10, places_after_decimal);no += 0.5;no = (int) no;no /= Math.pow(10, places_after_decimal);return no;
}
public static void arraycopy(Object source_array, int source_start_index,Object destination_array, int destination_start_index, int no_of_elements_to_copy)
{System.arraycopy(source_array, source_start_index, destination_array,
destination_start_index, no_of_elements_to_copy);
}
public static void arraycopy(Object source_array, Object destination_array,int no_of_elements_to_copy)
{System.arraycopy(source_array, 0, destination_array, 0,
no_of_elements_to_copy);}
public static void arraycopy(int[] source_array, int[] destination_array){
System.arraycopy(source_array, 0, destination_array, 0,source_array.length);
}
public static void arraycopy(double[] source_array, double[]destination_array)
{System.arraycopy(source_array, 0, destination_array, 0,
source_array.length);}
public static void arraycopy(char[] source_array, char[] destination_array){
System.arraycopy(source_array, 0, destination_array, 0,source_array.length);
}
public static void arraycopy(String[] source_array, String[]destination_array)
{System.arraycopy(source_array, 0, destination_array, 0,
source_array.length);}
public static void Sop(char[] ch){
8/14/2019 Full Cta Proj
13/36
System.out.print(ch);}
public static void Sopln(char[] ch){
Sop(ch);Sopln();
}
public static void exit(String s){
Sopln(s);exit();
}
public static int menu(String[] str){
for (int i = 0; i < str.length; i++)Sopln((i + 1) + ") " + str[i]);
if (str.length != 0)Sop("\nPlease enter your choice: ");
return str.length > 0 ? rInt("\nPlease enter a valid choice") : 0;}
public static int menu(String str){
return menu(str.split(" "));}
public static int menu(String str, String seperator){
return menu(str.split(seperator));}
public static void Sopln(Object obj){
System.out.println(obj);}
public static void Sop(Object obj){
System.out.print(obj);}
}}}}}}}}}}}}}}}
8/14/2019 Full Cta Proj
14/36
package PROJECT_FILES;
import java.io.*;i
public class sort{
public void main() throws IOException{
String[] line = no_of_lines.records();int min, pos, tmp1;for (int i = 0; i < line.length - 1; i++){
String tmp = "";min = Integer.parseInt(line[i].substring(0, 4));pos = i;
for (int j = i + 1; j < line.length; j++)if ((tmp1 = Integer.parseInt(line[j].substring(0, 4))) < min){
min = tmp1;pos = j;
}tmp1 = 0;tmp = line[i];line[i] = line[pos];line[pos] = tmp;
}PrintWriter pw = new PrintWriter(new
FileWriter("PROJECT_FILES/report.dat"));
for (int i = 0; i < line.length; i++)pw.println(line[i]);
pw.close();}
}}}}}}}
8/14/2019 Full Cta Proj
15/36
package PROJECT_FILES;import javax.security.auth.callback.PasswordCallback;import java.io.*;i
public class password extends read{
public static void pass(String pass) throws IOException{
PasswordCallback pc = new PasswordCallback("This file is confedential andtop secret...\nPlease enter the password to continue.\n", false);
pc.setPassword(pass.toCharArray());Sopln(pc.getPrompt());for (int i = 0; ; i++){
String tmp = br.readLine();if (tmp.equals(new String(pc.getPassword())))
return;if (i == 2)
break;
if (!tmp.equals(""))Sopln("Access Denied, please retry\n");
else Sopln("Please enter a password");}Sopln("Access Denied. Please restart the application");exit();
}
public static void validate(){
try
8/14/2019 Full Cta Proj
16/36
{Thread.sleep(1000);Sop("\nPassword is valid");for (int i = 0; i < 4; i++){
Sop(".");Thread.sleep(500);
}
}catch (InterruptedException e){}Sopln("Proceed.");
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
package PROJECT_FILES;import java.io.*;i
public class add extends read{private String[] order = {"english language", "english literature", "hindi","mathematics", "physics","chemistry", "biology", "geography", "history_civics", "environmental education","seventh subject"},record = null;
8/14/2019 Full Cta Proj
17/36
public add() throws IOException{
record = no_of_lines.records();}
public void main() throws IOException{
try{
int tmp = 0, tmp3 = 0, tmp5 = 0, tmp6 = 0;String tmp1 = "";boolean tmp2 = false;double tmp4 = 0;while (!(tmp5 > 999 && tmp5 < 10000)){
if (tmp3 != 0)Sopln("Please enter a valid 4-digit perm number");
elseSopln("\nEnter Perm number (type 0 to cancel)");
tmp5 = rInt("Please enter a valid 4-digit perm number");
if (tmp5 == 0)return;
tmp3++;}{
for (int i = 0; i < record.length; i++)if (tmp5 == Integer.parseInt(record[i].substring(0, 4))){
Sopln("Record with this perm number alreadyexists!\n\nAddition Failed");
return;}
}
tmp3 = 0;while(!(tmp1.equals("A") || tmp1.equals("B") || tmp1.equals("C"))){
if (tmp3 == 0)Sopln("\nPlease enter the division");
elseSopln("Please enter a valid division (a, b or c)");
tmp1 = rString().trim().toUpperCase();tmp3++;
}switch (tmp1.charAt(0)){
case 'A' : tmp6 = 29; break;
//ENTER CORRECT NO OF STUDENTS IN EACH CLASS AT PRESENT...case 'B' : tmp6 = 29; break;case 'C' : tmp6 = 29;
}tmp3 = 0;do{
if (tmp3 == 0)Sopln("\nPlease enter the Roll number");
elseSopln("Please enter a valid roll number form 0 to " + tmp6);
8/14/2019 Full Cta Proj
18/36
tmp = rInt("Please enter a valid roll number");tmp3++;
}while (!(tmp > 0 && tmp
8/14/2019 Full Cta Proj
19/36
if (tmp3 == 0)Sopln("\nEnter seventh subject chosen (CTA, CA, FRE)");
else Sopln("Please enter the correct choice");tmp1 = (rString().trim().toUpperCase() + " a").split(" ")[0];if (tmp1.equals("COMP") || tmp1.equals("COMPUTER") ||
tmp1.equals("COMPUTERS"))tmp1 = "CTA";
else if (tmp1.equals("COMM") || tmp1.equals("COMMERCE") ||
tmp1.equals("COMMERCIAL") || tmp1.equals("COM") || tmp1.equals("COMERCE") ||tmp1.equals("COMERCIAL"))
tmp1 = "CA";else if (tmp1.equals("FRENCH") || tmp1.equals("FREN"))
tmp1 = "FRE";tmp3++;
}while (!(tmp1.equals("CTA") || tmp1.equals("CA") ||tmp1.equals("FRE")));
pw.println(tmp1);pw.close();Sopln("Addition Succesful");
}catch (IOException e) {}
new sort().main();}
}
8/14/2019 Full Cta Proj
20/36
package PROJECT_FILES;import java.io.*;
public class no_of_lines{
public static int main() throws IOException{
try
{int ctr = 0;BufferedReader fr = new BufferedReader(new
FileReader("PROJECT_FILES/report.dat"));while (fr.readLine() != null)
ctr++;fr.close();return ctr;
}catch (FileNotFoundException e){
return 0;}
}
public static String[] records() throws IOException{
try{
BufferedReader fr = new BufferedReader(newFileReader("PROJECT_FILES/report.dat"));
String[] rec = new String[main()];for (int i = 0; i < rec.length; i++)
rec[i] = fr.readLine();fr.close();return rec;
}catch (FileNotFoundException e){
return new String[0];}
}}
8/14/2019 Full Cta Proj
21/36
package PROJECT_FILES;import java.io.*;
public class change_pass extends read
{public void change_pass(char error_var, String pass) throws IOException{
String old_p = "";if (error_var == 'n'){
Sopln("Please enter old password");old_p = rString();
}Sopln("\nenter new password");String new_p1 = rString();Sopln("\nre-type new password");String new_p2 = rString();
lines(2);boolean flg = true;try{
Sop("Processing");for (int i = 0; i < 4; i++){
Thread.sleep(400);Sop('.');
}Sopln();Thread.sleep(500);if (error_var == 'n')
{if (!old_p.equals(pass)){
Sopln("Wrong Password\nAccess Denied");flg = false;
}else if (!new_p1.equals(new_p2)){
Sopln("Passwords don't match");flg = false;change_pass('y', pass);
8/14/2019 Full Cta Proj
22/36
}else if (new_p1.length() < 6){
Sopln("Password should be at least 6 characterslong");
flg = false;change_pass('y', pass);
}
}else if (error_var == 'y'){
if (!new_p1.equals(new_p2)){
Sopln("Passwords don't match");flg = false;change_pass('y', pass);
}else if (new_p1.length() < 6){
Sopln("Password should be at least 6 characterslong");
flg = false;change_pass('y', pass);
}}if (flg){
pass = new_p1;Thread.sleep(1000);Sopln("Password change successful");{
File tmp = new File("pass.passx");tmp.delete();PrintWriter pw = new PrintWriter(new
FileWriter("pass.passx"));pw.println(pass);pw.close();tmp.setReadOnly();
}}
}catch (InterruptedException e){}
}}
8/14/2019 Full Cta Proj
23/36
package PROJECT_FILES;import java.io.*;
public class search extends read{
private student[] students = null;
public search() throws IOException{
String[] tmp = no_of_lines.records();students = new student[tmp.length];for (int i = 0; i < tmp.length; i++)
students[i] = new student(tmp[i]);
}
public void main(){
String[] menu = "Perm number--Division--Roll number--Name--Marks--SeventhSubject--Cancel".split("--");
Sopln("Search by:-");switch(menu(menu)){
case 1 : pno(); break;case 2 : cls(); break;case 3 : rno(); break;case 4 : name(); break;
case 5 : mks(); break;case 6 : sub7(); break;case 7 : return;
}Sopln("\n\nSearch completed");
}
private void pno(){
int pno = 0;for (int i = 0; !(999 < pno && pno < 9999); i++)
8/14/2019 Full Cta Proj
24/36
{if (i == 0)
Sopln("Enter the perm number of the student you wish to search (0to cancel)");
else Sopln("Please enter a valid 4 digit perm number");pno = rInt("Please enter a valid perm number");if (pno == 0)
return;
}Sopln();int i;for (i = 0; i < students.length; i++)
if (students[i].perm_no == pno)break;
if (i != students.length)students[i].display();
else Sopln("Record of a student with this perm number is not available");}
private void cls(){
String cls = "";for (int i = 0; !(cls.equals("A") || cls.equals("B") || cls.equals("C"));
i++){
if (i == 0)Sopln("Enter the division of the student you wish to search (0 to
cancel)");else Sopln("Please enter a valid division (A, B, or C)");cls = rString().trim().toUpperCase();if (cls.equals("0"))
return;}student.title();
for (int i = 0; i < students.length; i++)if (cls.equals(students[i].clas))
students[i].disp();}
private void rno(){
int rno = 0;for (int i = 0; rno < 1 || rno > 29; i++) //Heighest roll
number from all classes{
if (i == 0)Sopln("\nPlease enter the Roll number");
elseSopln("Please enter a valid roll number form 0 to " + 29);
//Heighest roll number from all classesrno = rInt("Please enter a valid roll number");i++;
}String tmp = "";int i;for (i = 0; i < students.length; i++)
if (students[i].roll_no == rno)tmp+= i + " ";
8/14/2019 Full Cta Proj
25/36
String[] tmp1 = tmp.trim().split(" ");if (tmp1.length == 0)
Sopln("No student record available");else if (tmp1.length == 1)
students[Integer.parseInt(tmp)].display();else{
student.title();
for (int j = 0; j < tmp1.length; j++)Sopln(students[Integer.parseInt(tmp1[j])].perm_no + "\t" +
students[Integer.parseInt(tmp1[j])].clas + "\t" +students[Integer.parseInt(tmp1[j])].roll_no + "\t" +students[Integer.parseInt(tmp1[j])].name);
}}
private void name(){}
private void mks()
{}
private void sub7(){
String tmp1 = "";for (int i = 0; !(tmp1.equals("CTA") || tmp1.equals("CA") ||
tmp1.equals("FRE")); i++){
if (i == 0)Sopln("\nEnter seventh subject chosen (CTA, CA, FRE)");
else Sopln("Please enter the correct choice");tmp1 = (rString().trim().toUpperCase() + " a").split(" ")[0];
if (tmp1.equals("COMP") || tmp1.equals("COMPUTER") ||tmp1.equals("COMPUTERS"))
tmp1 = "CTA";else if (tmp1.equals("COMM") || tmp1.equals("COMMERCE") ||
tmp1.equals("COMMERCIAL") || tmp1.equals("COM") || tmp1.equals("COMERCE") ||tmp1.equals("COMERCIAL"))
tmp1 = "CA";else if (tmp1.equals("FRENCH") || tmp1.equals("FREN"))
tmp1 = "FRE";}Sopln("\nStudents with seventh subject " + tmp1 + "\n");student.title();for (int i = 0; i < students.length; i++)
if (students[i].seventh_sub.equals(tmp1))students[i].disp();
}}
8/14/2019 Full Cta Proj
26/36
package PROJECT_FILES;import java.io.PrintWriter;
public class student{
public String name, clas;public double eng1, eng2, hindi, maths, phy, chem, bio, geo, hist_civ, ee,
sub7;public String seventh_sub;public int perm_no, roll_no;/* default file saving order is:-
perm_no-clas-roll_no-name-e1-e2-hin-mat-phy-che-bio-geo-h_c-ee-sub7-seventh_sub
*/
public student(){
name = null;clas = null;eng1 = eng2 = hindi = maths = phy = chem = bio = geo = hist_civ = ee =
sub7 = 0;perm_no = roll_no = 0;
}
public student(String name, String clas, double english_language, doubleenglish_literature, double hindi, double mathematics, double physics, doublechemistry, double biology, double geography, double history_civics, doubleenvironmental_education, double seventh_subject, String subject7, intpermenant_number, int roll_number)
{this.name = name;
8/14/2019 Full Cta Proj
27/36
this.clas = clas;eng1 = english_language;eng2 = english_literature;this.hindi = hindi;maths = mathematics;phy = physics;chem = chemistry;bio = biology;
geo = geography;hist_civ = history_civics;ee = environmental_education;sub7 = seventh_subject;perm_no = permenant_number;roll_no = roll_number;seventh_sub = subject7;
}
public student(String record){
String[] str = record.split("-");int i = 0;
perm_no = Integer.parseInt(str[i++]);clas = str[i++];roll_no = Integer.parseInt(str[i++]);name = str[i++];eng1 = Double.parseDouble(str[i++]);eng2 = Double.parseDouble(str[i++]);hindi = Double.parseDouble(str[i++]);maths = Double.parseDouble(str[i++]);phy = Double.parseDouble(str[i++]);chem = Double.parseDouble(str[i++]);bio = Double.parseDouble(str[i++]);geo = Double.parseDouble(str[i++]);hist_civ = Double.parseDouble(str[i++]);
ee = Double.parseDouble(str[i++]);sub7 = Double.parseDouble(str[i++]);seventh_sub = str[i];
}
public void display(){
double total = eng1 + eng2 + hindi + maths + phy + chem + bio + geo +hist_civ + ee + sub7,
percent = read.round(total / 11, 2);read.Sopln("Perm. no.\t\t" + perm_no + "\nClass\t\t\t10" + clas + "\nRoll.
no.\t\t" + roll_no + "\nName\t\t\t" + name + "\nEnglish Lang.\t\t" + eng1 +"\nEnglish Lit.\t\t" + eng2 + "\nHindi\t\t\t" + hindi + "\nMathmatics\t\t" + maths
+ "\nPhysics\t\t\t" + phy + "\nChemistry\t\t" + chem +"\nBiology\t\t\t" + bio + "\nGeography\t" + geo + "\nHistory/Civics\t" +
hist_civ + "\nEnvironmental Education\t" + ee);read.Sopln(seventh_sub + "\t\t\t" + sub7);read.Sopln("Total on 1100\t\t" + total + "\nPercentage\t\t\t" + percent +
"%");}
public void add() throws java.io.IOException{
PrintWriter pw = new PrintWriter(new
8/14/2019 Full Cta Proj
28/36
java.io.FileWriter("PROJECT_FILES/report.dat", true));pw.println(perm_no + "-" + clas + "-" + roll_no + "-" + name + "-" + eng1
+ "-" + eng2 + "-" + hindi + "-" + maths + "-" + phy + "-" + chem + "-" + bio +"-" + geo + "-" + hist_civ + "-" + ee + "-" + sub7 + "-" + seventh_sub);
pw.close();}
public void disp()
{read.Sopln(perm_no + "\t10" + clas + "\t" + roll_no + "\t" + name);
}
public static void title(){
read.Sopln("perm no\tclass\troll no\tname");}
}
package PROJECT_FILES;import java.io.*;
public class edit extends read{
public void main(){
8/14/2019 Full Cta Proj
29/36
}}
package PROJECT_FILES;import java.io.*;
public class delete extends read{
String[] rec = null;
public delete() throws IOException{
rec = no_of_lines.records();}
public void main() throws IOException{
Sopln("perm_no\tclass\troll_no\tname");for (int i = 0; i < rec.length; i++){
String[] tmp = rec[i].split("-");int t = 0;Sopln(tmp[t++] + "\t" + tmp[t++] + "\t" + tmp[t++] + "\t" + tmp[t++]);
}Sopln("\nPlease enter the perm number of the student whose entry you wish
8/14/2019 Full Cta Proj
30/36
to delete (0 to cancel, 1 to delete all)");int choice = rInt("Please enter a valid choice");if (choice == 0)
return;else if (choice == 1){
Sopln("Are you sure you want to delete all? (Weird or no input will betaken as 'NO'");
String tmp = rString().trim().toUpperCase();if (tmp.equals("Y") || tmp.equals("YES") || tmp.equals("YA") ||
tmp.equals("YUP") || tmp.equals("SURE") || tmp.equals("YO")){
File f1 = new File("PROJECT_FILES/report.dat");Sopln("Delete " + (!f1.exists() || f1.delete() ? "" : "un") +
"successful");return;
}}else delete(choice);new sort().main();
}
public void delete(int perm) throws IOException{
int tmp = 0;PrintWriter pw = new PrintWriter(new
FileWriter("PROJECT_FILES/report.dat"));for (int i = 0; i < rec.length; i++)
if (perm != Integer.parseInt(rec[i].substring(0, 4))){
pw.println(rec[i]);tmp++;
}if (tmp != 0)
Sopln("Delete successful");else
Sopln("No entry with this perm number is present");pw.close();
}}
8/14/2019 Full Cta Proj
31/36
package applets;
import java.awt.*;import java.awt.event.*;import java.applet.Applet;
import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JButton;import javax.swing.JApplet;
public class Title extends JApplet implements Runnable, MouseListener{
String banner; // The text to be displayedchar bannerChars[]; // The same text as an array of characterschar attributes[]; // Character attributes ('^' for superscript)Thread runner = null; // The thread that is displaying the textboolean threadSuspended; // True when thread suspended (via mouse click)boolean tmp = true;
static JFrame_ frame = null;static Thread tmpthread = null;JFrame frame2 = null;
static final int REGULAR_WD = 15;static final int REGULAR_HT = 36;static final int SMALL_WD = 12;static final int SMALL_HT = 24;
Font regularFont = new Font("Comic Sans MS", Font.BOLD, REGULAR_HT);Font smallFont = new Font("Comic Sans MS", Font.BOLD, SMALL_HT);
public void main()
{frame = new JFrame_("TEXT");frame.getContentPane().add(new Title());frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);exit();frame.pack();frame.setSize(500, 100);frame.show();updater();
}
8/14/2019 Full Cta Proj
32/36
public static void thread(Thread thread){
tmpthread = thread;}
public void exit(){
JButton exit = new JButton("CLOSE");exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {frame.dispose();frame2.dispose();tmpthread.stop();
}});JPanel panel = new JPanel();panel.add(exit);frame2 = new JFrame("CLOSE");frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame2.add(panel);
frame2.pack();frame2.setLocation(200,200);frame2.pack();frame2.setSize(200, 75);frame2.show();frame2.setAlwaysOnTop(true);
}
private void updater(){
for (int i = 0; frame != null; i++)try{
Thread.sleep(500);frame.show();
} catch (InterruptedException e) {}}
public void init(){if (tmp)
banner = getParameter("Do not close this window");if (banner == null) {
banner = " Sharada Mandir Term 1 Report";}
int bannerLength = banner.length();StringBuffer bc = new StringBuffer(bannerLength);StringBuffer attrs = new StringBuffer(bannerLength);int wd = 0;for (int i = 0; i < bannerLength; i++) {
char c = banner.charAt(i);char a = 0;if (c == '^') {i++;if (i < bannerLength) {
c = banner.charAt(i);
8/14/2019 Full Cta Proj
33/36
a = '^';wd += SMALL_WD - REGULAR_WD;
} else {break;
}}bc.append(c);attrs.append(a);
wd += REGULAR_WD;}
bannerLength = bc.length();bannerChars = new char[bannerLength];attributes = new char[bannerLength];bc.getChars(0, bannerLength, bannerChars, 0);attrs.getChars(0, bannerLength, attributes, 0);
threadSuspended = false;resize(wd + 10, 50);addMouseListener(this);}
public void destroy() {removeMouseListener(this);
}
public void start() {runner = new Thread(this);runner.start();
}
public synchronized void stop() {runner = null;
if (threadSuspended) {
threadSuspended = false;notify();
}}
public void run() {Thread me = Thread.currentThread();while (runner == me) {
try {Thread.sleep(100);synchronized(this) {
while (threadSuspended) {wait();
}}
} catch (InterruptedException e){}repaint();
}}
public void paint(Graphics g) {
tmp = false;
8/14/2019 Full Cta Proj
34/36
init();int length;try{length = bannerChars.length;}catch (NullPointerException e){bannerChars = " Sharada Mandir Term 1 Report".toCharArray();
length = bannerChars.length;}for (int i = 0, x = 0; i < length; i++) {
int wd, ht;if (attributes[i] == '^') {wd = SMALL_WD;ht = SMALL_HT;g.setFont(smallFont);} else {wd = REGULAR_WD;ht = REGULAR_HT;g.setFont(regularFont);}
int px = (int) (10 * Math.random() + x);int py = (int) (10 * Math.random() + ht);g.drawChars(bannerChars, i, 1, px, py);
x += wd;}}
public synchronized void mousePressed(MouseEvent e) {e.consume();threadSuspended = !threadSuspended;if (!threadSuspended)
notify();}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {}
public String getAppletInfo() {return "Title: Title\nAuthor: Pratik\nDisplays a text banner that
jitters.";
}
public String[][] getParameterInfo() {String pinfo[][] = {
{"text", "string", "Text to display"},};return pinfo;
}}
8/14/2019 Full Cta Proj
35/36
package applets;
public class JFrame_ extends javax.swing.JFrame{
protected JFrame_(String name){
super(name);}
}
8/14/2019 Full Cta Proj
36/36
Remaining!!!
Delete class column!EDIT!SEARCH incomplete!see class add & search!applets in a frame in terminal window!add a sample method (Ctrl + M) and put documentation in that format!search.rno() not working!