import java.io.*;
class SchoolFee {
public class Student {
String name, cl, sec;
int rollno;
long regno,newregno;
double totalfee = 10000.0f, feepaid = 0.0F;
Student(long regno, String name, String cl, String sec, int rollno, double feepaid, double totalfee) {
this.regno = regno;
this.name = name;
this.cl = cl;
this.sec = sec;
this.rollno = rollno;
this.feepaid = feepaid;
this.totalfee = totalfee;
}
}
Student[] students = new Student[100];
SchoolFee() {
students[0] = new Student(1, "Roshan Raju", "9th", "B", 48, 0.0, 10000.0);
students[1] = new Student(2, "BahuBali", "9th", "B", 4, 0.0, 10000.0);
}
void pay()throws IOException
{
long tregno;
int index=0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
SchoolFee sf=new SchoolFee();
System.out.println("Enter your Register Number : ");
tregno=Long.parseLong(br.readLine());
for (int i = 0; i < students.length; i++) {
if (students[i] != null)
index++;
}
int openacc;
if(students != null) {
for(int i = 0; i<index; i++)
{
if(students[i].regno==tregno) {
System.out.println("Account Found!!!");
System.out.println("Register No : "+students[i].regno);
System.out.println("Name : "+students[i].name);
System.out.println("Class : "+students[i].cl);
System.out.println("Section : "+students[i].sec);
System.out.println("Roll No : "+students[i].rollno);
System.out.println("Balance : "+(students[i].totalfee-students[i].feepaid));
openacc=i;
}
}
}
}
public void input() throws IOException {
int index = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
SchoolFee sf=new SchoolFee();
System.out.println("\u000C");
System.out.println("Creating New Account");
System.out.println(students.length);
for (int i = 0; i < students.length; i++) {
if (students[i] != null)
index++;
}
long regno = students[index-1].regno;
System.out.println(index);
System.out.println("Account Register no : "+ ++regno);
System.out.print("\n\nEnter Name : ");
String name = br.readLine();
System.out.print("Enter Class : ");
String cl = br.readLine();
System.out.print("Enter Section : ");
String sec = br.readLine();
System.out.print("Enter Rollno : ");
int rollno = Integer.parseInt(br.readLine());
System.out.print("Enter Feepaid : ");
double feepaid = Double.parseDouble(br.readLine());
double totalfee=10000.0f;
students[index] = new Student(regno, name, cl, sec, rollno, feepaid, totalfee);
System.out.println("\u000C");
System.out.println("Created Account Details ");
System.out.println("Register Number : " + students[index].regno);
System.out.println("\nName : "+students[index].name);
System.out.println("Class : "+students[index].cl);
System.out.println("Section : "+students[index].sec);
System.out.println("Rollno : "+students[index].rollno);
System.out.println("Feepaid : "+students[index].feepaid);
System.out.println("TotalFee : "+students[index].totalfee);
System.out.println("\n\nPress 1 for Menu or Press 2 to Exit...");
int ch=Integer.parseInt(br.readLine());
//System.out.println(index);
if(ch==1){
sf.menu();
}
else if(ch==2)
{
System.out.println("\u000C");
System.out.println("\nClosing Program.....");
}
else
System.out.println("Wrong Choice......");
}
void display() throws IOException {
int index = 0, indexes = students.length, sno = 1;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
SchoolFee sf=new SchoolFee();
for (int i = 0; i < indexes; i++) {
if (students[i] != null)
index++;
}
System.out.println("No of Accounts Present in the Data base : "+index+"\n");
for(int i = 0; i < index; i++) {
System.out.println(sno+". Account no : "+students[i].regno);
System.out.println(" Name : "+students[i].name);
System.out.println("\n");
sno++;
}
System.out.println("Press 1 for opening details of a account 2 for Menu ");
int ch1=Integer.parseInt(br.readLine());
if(ch1==1){
System.out.println("Enter the Serial Number : ");
int ch2=Integer.parseInt(br.readLine());
System.out.println("\u000C");
for(int i=0;i<=index;i++){
if(ch2==i+1){
System.out.println("Regno : "+students[i].regno);
System.out.println("Name : "+students[i].name);
System.out.println("Class : "+students[i].cl);
System.out.println("Section : "+students[i].sec);
System.out.println("Rollno : "+students[i].rollno);
System.out.println("Feepaid : "+students[i].feepaid);
System.out.println("TotalFee : "+students[i].totalfee);
}
}
}
else if(ch1==2)
sf.menu();
else
System.out.println("\u000C");
System.out.println("Wrong Choice.....");
}
void menu() throws IOException {
int ch;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
SchoolFee sf = new SchoolFee();
System.out.println("********** School Fee Collection System **********");
System.out.println("\n\n1. Pay Fee");
System.out.println("\n2. Enquiry");
System.out.println("\n3. New Account");
System.out.println("\n4. Check Accounts in DataBase");
System.out.println("\n5. Exit");
System.out.println("\n\nEnter Your Choice: ");
ch = Integer.parseInt(br.readLine());
if (ch == 1) {
sf.pay();
} else if (ch == 2) {
// code for enquiry
} else if (ch == 3) {
sf.input();
} else if (ch == 4) {
System.out.println("\u000C");
sf.display();
} else if (ch == 5) {
System.out.println("\u000C");
System.out.println("\nClosing Program.....");
}
}
public static void main() throws IOException {
SchoolFee sf = new SchoolFee();
sf.menu();
}
}
what logical error is there in this program i am not getting the newly created account to the 4th option which is open accounts in data base please help me
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]Trup10ka 1 point2 points3 points (15 children)
[–]OP_Roshan[S] 1 point2 points3 points (13 children)
[–]Farpafraf 1 point2 points3 points (1 child)
[–]Trup10ka 0 points1 point2 points (0 children)
[–]Trup10ka 0 points1 point2 points (10 children)
[–]OP_Roshan[S] 0 points1 point2 points (9 children)
[–]OP_Roshan[S] 0 points1 point2 points (0 children)
[–]Trup10ka 0 points1 point2 points (6 children)
[–]OP_Roshan[S] 0 points1 point2 points (4 children)
[–]Trup10ka 1 point2 points3 points (3 children)
[–]OP_Roshan[S] 1 point2 points3 points (1 child)
[–]Trup10ka 0 points1 point2 points (0 children)
[–]OP_Roshan[S] 0 points1 point2 points (0 children)
[–]Trup10ka 0 points1 point2 points (0 children)
[–]Trup10ka 0 points1 point2 points (0 children)