hi there,
i have started to work on another program. it is a gym member database. where members registration details are to be added.
A Gym member record consists of membership number, name, postcode and fee.
there has to be a class definition to represent Gym membership details.
With a main method that declares and initialises two new Gym membership objects.
Write a method to request data items from the user to fill both the new Gym member objects.
and a method to display to the screen the names and membership numbers of both members.
Example data entry ( “Z123456”, “Paul Jones”, “HN78HG”, 250);
i have written what i could but when i compile the program it comes up with errors that i am having a problem understanding.
could any one HELP me through with this program.
thanks
import javax.swing.JOptionPane;
import java.io.*;
public class gym
{
public static void main (String [] args) throws IOException
{
int Counter=0;
member[] members = new members[45];
Controller(members, Counter);
}
public static void Controller(members[] values, int Counter) throws IOException
{
int Control=Integer.parseInt(JOptionPane.showInputDial og("MeNu\n" + "0 To Quit\n" + "1 to Add new employee" + "2 to Print the Employee" + "3 to Search\n"));
while (Control!=0)
{
if (Control==1)
{
for (int count=0; count<1; count++)
{
values[Counter]=new members();
String name=JOptionPane.showInputDialog("Name of member", "member");
int number=JOptionPane.showInputDialog("gym number", "gym number");
int postcode=Integer.parseInt(JOptionPane.showInputDia log("postcode","postcode"));
values[Counter]= new Database(name, number, postcode);
Counter++;
}
} // end of if 1
else if (Control==2)
{
for (int count=0; count<Counter; count++)
{
values[count].showValues();
}
}
else if (Control==3)
{
int DoSearch=Integer.parseInt(JOptionPane.showInputDia log("Searching\n" + "1 to Search member\n" + "2 to Search gym number\n" + "3 to Search postcode"));
if (DoSearch==1)
{
String nameSearching=JOptionPane.showInputDialog("Search Name of member", "Name of member");
int result=nameSearch(values, nameSearching , Control);
if (result==-5)
System.out.println("member That you Searched -> Not Found");
else
{
System.out.println(nameSearching + "\nis found in position\n" + (result+1));
values[result].showValues();
}
}
else if (DoSearch==2)
{
int numberSearching=JOptionPane.showInputDialog("Searc h gym number", "Search gym number");
int result=numberSearch(values, numberSearching , Control);
if (result==-5)
System.out.println("number That you Searched -> Not Found");
else
{
System.out.println(numberSearching + "\nis found in position\n" + (result+1));
values[result].showValues();
}
}
else if (DoSearch==3)
{
int postcodeSearching=Integer.parseInt(JOptionPane.sho wInputDialog("Search postcode", "Search postcode"));
int result=number(values, numberSearching , Control);
if (result==-5)
System.out.println("postcode That you Searched -> Not Found");
else
{
System.out.println(postcodeSearching + "\nis found in position\n" + (result+1));
values[result].showValues();
}
}
}
Control=Integer.parseInt(JOptionPane.showInputDial og("MeNu\n" + "0 To Quit\n" + "1 to Add new member\n" + "2 to Print gym number\n" + "3 to Search postcode\n"));
}
}
public static int nameSearch(members[] values, String Thekey, int Size)
{
for (int y=0; y<Size; y++)
{
if (values[y].name.equals(Thekey))
{
return y;
}
}
return -5;
}
public static int numberSearch(members[] values, int Thekey, int Size)
{
for (int h=0; h<Size; h++)
{
if (values[h].number.equalsIgnoreCase(Thekey))
{
return h;
}
}
return -5;
}
public static int postcode(members[] values, int Thekey, int Size)
{
for (int r=0; r<Size; r++)
{
if (values[r].postcode==Thekey)
{
return r;
}
}
return -5;
}
}
class gym
{
String name;
int number;
int postcode;
public gym(String n, int nm, int p)
{
name=n;
number=nm;
postcode=p;
}
public members()
{
name="Edward Downing";
number="12345";
postcode=2009;
}
public void showValues()
{
System.out.println("member " + " number " + " postcode ");
}
}