I need help with the following questions, any assistance is greatly appreciated. I have added the code
Question:
I need help with the following questions, any assistance is greatly appreciated. I have added the code that I have figured out so far, and the files that accompany it. Thank you so much!
Add code to the Modify member method. In this method, you will increment the member count (mcount) and prompt the user for new member data to be read into the member parallel arrays. You will have to change the call to the modify_member method, passing the arrays and the member count
Add code to the Modify Registration method In this method, you will increment the registration count (rcount) and prompt the user for new registration data to be read into the registration parallel arrays. You will have to change the call to the modify_registration method, passing the arrays ant the registration count The possible class names are: Yoga Karate AerobicsI AerobicsII SwimmingI SwimmingII
The current 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) { 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 rcount=-1; int [] regCodes = new int [100]; String [] regClasses = new String [100];
int selection; String snumber; mcount=read_member(mcount,code,name,type,age,gender,payment); rcount=read_registration(rcount, regCodes, regClasses); 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 //******************************************************************* 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; } //******************************************************************* public static int read_registration(int rcount, int[]regCodes, String[]regClasses) { String newLine; try { BufferedReader register_file = new BufferedReader(new FileReader("register.txt")); while ((newLine = register_file.readLine()) != null) { StringTokenizer delimiter = new StringTokenizer(newLine,"#"); rcount=rcount+1; regCodes[rcount] = Integer.parseInt(delimiter.nextToken()); regClasses[rcount] = delimiter.nextToken(); } register_file.close(); } catch (IOException error) { System.out.println("Error on file read " +error); } return rcount; } //******************************************************************* 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; } //*******************************************************************
public static void Modify_member() { System.out.println("executing Modify_member"); } //*******************************************************************
public static void Modify_registration() { System.out.println("executing Modify_registration"); } //*******************************************************************
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill