import java.io.*;
import java.util.Scanner;
public class AdvExerProg1 {
static String studentList[];
static int studCount;
static Scanner s = new Scanner(System.in);
public static void main(String args[])throws IOException{
char ops ='N';
char save='Y';
String File="student.txt";
String Lastname,Firstname,Record= "";
String Rec =":";
boolean quit =false;
boolean done = false;
int record=0;
FileWriter txtFile =new FileWriter(File,true);
BufferedWriter studFile = new BufferedWriter(txtFile);
studentList = new String[5];
studCount = 0;
studentList = new String[5];
studCount = 0;
do{
record ++;
Record =Rec+record;
System.out.print("Record"+Record+"\n");
System.out.println("---------------------------------------");
System.out.print("Enter Student FirstName:");
Firstname=s.next();
System.out.print("Enter Students Lastname:");
Lastname=s.next();
Record = Lastname +", "+Firstname;
studentList[studCount]=Record;
studFile.write(Record);
studFile.newLine();
studCount ++;
z
if(ops==confirmYesNo("Another Student?"))
done =true;
}while (!done);
if(studCount!=0){
System.out.print("--------List of "+studCount+"Students---------\n");
for(int n=0;n<studCount;n++){
System.out.println(studentList[n]);
}
}
System.out.print("Press any key to continue:");
ReadChar();
System.out.print("bye bye !!!!");
System.exit(0);
}
public static char ReadChar(){
String data;
char chr;
data=s.next();
data=data.toUpperCase();
data=data.trim();
chr=data.charAt(0);
return chr;
}
public static char confirmYesNo(String msg){
char opt='n';
do{
System.out.print("\n"+msg+"[Y/N]->");
opt = ReadChar();
}while(opt!= 'Y' && opt !='N');
return opt;
}
}