Hello, I am having trouble with the section below, which asks me to fix the Report method
Question:
Hello, I am having trouble with the section below, which asks me to fix the "Report" method found in the code below. The report method pulls from two .txt files, one named "member.txt" and the other "register.txt".
1. I am using Eclipse IDE
2. The contents of both text files are located in the comments
Any guidance is much appreciated! Thanks,
- Add code to the Report Method
- You will have to change the call to the report method, passing the arrays and the counts
- Change the menu text to the wording below
- All Member Information
- All Registration Information
- All Members of a Specific type
- All Members between a specific age range
- All Members of a specific gender
- Specific Member's Registration
- Report 7
- Report 8
- Report 9
- Report 10
- Exit Report Menu
- Each report is defined as follows:
- All Member Information - Displays all information on all members
- All Registration information -Display all information for all registrations
- All Members of a Specific type- Prompt for the type and then display all information for members of that type
- All Members between a specific age range - Prompt for the beginning and ending age, then display all member information for the members within the date range
- All Members of a specific gender - Prompt for the gender and then display all members of that gender.
- Specific Member's Registration - List of all classes a specific member is signed up for (prompt for the member code) You must display all of the member's information and then search the registration arrays and when there is a match on the member's code, print the list of all classes he is registered for
- Report 7 print message "Report 7 to be defined later"
- Report 8 print message "Report 8 to be defined later"
- Report 9 print message "Report 9 to be defined later"
- Report 10 print message "Report 10 to be defined later"
CODE:
package ymca; import javax.swing.JOptionPane; import java.io.*; import java.util.*; import java.text.*; public class ymca { public static void main(String[] args) {
//Main Method********************************************** int mcount=-1,i; int [] code = new int[100]; String [] type = new String [100]; String [] name = new String [100]; int [] age = new int [100]; String [] gender = new String[100]; double [] payment = new double [100];
int selection; String snumber; mcount=read_member(mcount,code,name,type,age,gender,payment); read_registration(); selection = menu(); while(selection !=4) { if(selection==1) Modify_member(); else if(selection==2) Modify_registration(); else if(selection==3) Report(mcount,code,name,type,age,gender,payment); selection = menu(); }//while loop exit_program(); System.exit(0); }//main method //Main Method END***************************************
//read_member Method*********************************** public static int read_member(int mcount,int[]code,String[]name,String[]type,int[]age,String[]gender,double[]payment) { int i; String newLine; try { //define a file variable for Buffered read BufferedReader member_file = new BufferedReader(new FileReader("member.txt")); //read lines in file until there are no more lines in the file to read while ((newLine = member_file.readLine()) != null) { //there is a "#" between each data item in each line StringTokenizer delimiter = new StringTokenizer(newLine,"#"); mcount=mcount+1; code[mcount] = Integer.parseInt(delimiter.nextToken()); name[mcount] =delimiter.nextToken(); type[mcount] =delimiter.nextToken(); age[mcount] = Integer.parseInt(delimiter.nextToken()); gender[mcount] =delimiter.nextToken(); payment[mcount] = Double.parseDouble(delimiter.nextToken()); }//while loop member_file.close(); }//end try catch (IOException error) { //there was an error on the file writing System.out.println("Error on file read " + error); }//error on read return mcount; } //read_member Method END****************************************
//read_registration Method****************************** public static void read_registration() { System.out.println("executing read_registration"); } //read_registration Method END**************************************
//Menu Method*********************************************** public static int menu() { String snum; int selection; String Output = "Pittsburgh Area YMCA" + " " + "1. Add/Modify Member Information" + " " + "2. Add/Modify Class Registrations " + " " + "3. Report Section" + " " + "4. Exit the System"+ " " +" " + "Please make your seleciton"; snum = JOptionPane.showInputDialog(null, Output, "",JOptionPane.QUESTION_MESSAGE); selection = Integer.parseInt(snum); return selection; } //Menu Method END*********************************************
//Modify_member Method*******************************************
public static void Modify_member() { System.out.println("executing Modify_member"); } //Modify_member Method END***********************************************
//Modify_registration Method*******************************************
public static void Modify_registration() { System.out.println("executing Modify_registration"); } //Modify_registration Method END*******************************************
//REPORT METHOD START****************************************************
public static void Report(int mcount,int[]code,String[]name,String[]type,int[]age,String[]gender,double[]payment) { int selection,i; String value; String words= "Pittsburgh Area YMCA"+" " + "1. All Member Info"+" " + "2. Report 2"+" " + "3. Report 3"+" " + "4. Report 4"+" " + "5. Report 5"+" " + "6. Report 6"+" " + "7. Report 7"+" " + "8. Report 8"+" " + "9. Report 9"+" " + "10. Report 10"+" " + "11. Exit Report Menu"+" " + " Please make your selection "; value=JOptionPane.showInputDialog(null, words, "Input Data", JOptionPane.QUESTION_MESSAGE); selection=Integer.parseInt(value); while (selection != 11) { if (selection == 1) { System.out.println("All Member Information"); for(i=0;i<=mcount;++i) { System.out.println(code[i]+" "+name[i]+" "+type[i]+" "+age[i]+" "+gender[i]+" "+payment[i]); } }//end of report 1 else if (selection == 2) { System.out.println("Add Code here for Report #2"); }//end of report 2 else if (selection == 3) { System.out.println("Add Code here for Report #3"); }//end of report 3 else if (selection == 4) { System.out.println("Add Code here for Report #4"); }//end of report 4 else if (selection == 5) { System.out.println("Add Code here for Report #5"); }//end of report 5 else if (selection == 6) { System.out.println("Add Code here for Report #6"); }//end of report 6 else if (selection == 7) { System.out.println("Add Code here for Report #7"); }//end of report 7 else if (selection == 8) { System.out.println("Add Code here for Report #8"); }//end of report 8 else if (selection == 9) { System.out.println("Add Code here for Report #9"); }//end of report 9 else if (selection == 10) { System.out.println("Add Code here for Report #10"); }//end of report 10 value=JOptionPane.showInputDialog(null, words, "Input Data", JOptionPane.QUESTION_MESSAGE); selection=Integer.parseInt(value); }//end of while loop } //REPORT METHOD END******************************************
//exit_program Method******************************************
public static void exit_program() { System.out.println("executing exit_system"); } //exit_program Method END************************************************
}