These are the suggestion for my project. Do you mind having a look

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • max3
    New Member
    • Jul 2007
    • 13

    These are the suggestion for my project. Do you mind having a look

    Step Description of Task Remark
    1 Create a class to represent the student
    This class is to define the following data items:
    o declare the variables required to store the data of one student (id, name, surname, group)
    assign default values to each of these variables
    2 Create a number of methods in this class to be able to:
    o set the values (set methods) for each of these variables from another class
    o return the values of individual variables of this class (get methods) to a calling class
    o to enter via keyboard the values for all the variables for a single student e.g.
    o setID()
    o setName()
    o setSurname()
    o setGroup()
    o getID()
    o getName()
    o getSurname()
    o getGroup()
    o enterDetails()
    3 Create a main class to declare system variables and control the primary interface to the system

    This class has to have a main() method.

    4
    Declare a data structure e.g. an array of 10 objects of type student

    Student studentList[] = new Student[10];
    5 In the main class create a process to input the details of 10 students. You can use a loop structure to do the following set of actions for each student:
    i) Assign a new instance of the student class to an array element
    ii) Call the methods to enter each of the student details (id, name, surname, group) , set the values to the class variables of that array element
    repeat statements like :

    studentList[n] = new Student();
    studentList[n].enterDetails() ;


    6 Add a set of statements to allow the user to input an element number and then enter the details of the student and replace the current array element values with the input values. to assign one attribute e.g
    System.out.prin tlin(“Enter Name: “);
    studentList[n].setName(Keyboa rd.readString() ))
    7 Add a set of statements to allow the user to input an element number and then display the details of the student e.g. // to display one attribute

    System.out.prin tlin(“Name: “+ studentList[n].getName);
    8 In the main class create a process to display the details of the 10 students you can use a loop structure to display the details of each student using the get function for each class variable

    for ( ...; ... ; ...) {
    ....
    System.out.prin t(“Name: “+ studentList[n].getName);
    ...
    ...
    }
    9 In the main class add stateme nts to create a menu of options as follows:
    a. Enter details of a list of students and store in array
    b. Enter details of a single student
    c. Display details of a single student
    d. Display details of list of students
    e. Exit the system

    Add a statement to input the user’s choice
    // a menu

    // display option 1
    // display opton 2
    // display option 3
    ..
    ..
    // enter choice
    10 Add statements to be able to perform each option depending on the selection.
    // input option

    switch (option)
    case ‘0’:
    break;
    case ‘1’:
    // statements for option 1
    break;
    case ‘2’:
    // statements for option 2
    break;
    case ’3’:
    ..
    ..

    }

    11 In the main class, create a loop to repeat steps b, c and d (options display, option input , option processing) until the exit option is selected do {
    // display
    // input
    // switch
    }
    while option != ‘0’


    This is how am I programming am I on the right track
    I still have a systnex error expected ";" on bold line. please help.This project have a deadline for the 23rd july
    public class main_class
    {
    public static void main (String args []){
    Student StudentList a [] = new Student[10];

    a.add("Ryan");
    a.add("Robert") ;
    a.add("Victor") ;
    a.add("Jim");
    a.add("Sammy");
    a.add("Leo");
    a.add("Mauro");
    a.add("Glen");
    a.add("Kyle");
    a.add("Kurt");


    Iterator i = a.iterator();
    while (i.hasNext()) {
    System.out.prin tln(i.next());
    }
    }
    }
    StudentList[n] = new student();
    StudentList[n].enterDetails() ;



    System.out.prin tln("Enter id");
    StudentList[n].setid(Keyboard .readString()))

    System.out.prin tln("Enter Name");
    StudentList[n].setName(Keyboa rd.readString() ))

    System.out.prin tln("Enter Surname");
    StudentList[n].setSurname(Key board.readStrin g()))

    System.out.prin tln("Enter Group");
    StudentList[n].setGroup(Keybo ard.readString( )))


    System.out.prin tln("id:"+Stude ntList[n].getid);
    System.out.prin tln("Name:"+Stu dentList[n].getName);
    System.out.prin tln("Surname:"+ StudentList[n].getSurname);
    System.out.prin tln("Group:"+St udentList[n].getGroup);


    for(id;Name;Sur name;Group){

    System.out.prin tln("id:"+Stude ntList[n].getid);
    System.out.prin tln("Name:"+Stu dentList[n].getName);
    System.out.prin tln("Surname:"+ StudentList[n].getSurname);
    System.out.prin tln("Group:"+St udentList[n].getGroup);
    }
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by max3
    I still have a systnex error expected ";" on bold line. please help.This project have a deadline for the 23rd july
    Student StudentList a [] = new Student[10];
    You mean this line? Look what you've typed: a is an array of what type? Student
    or StudentList? That's what your compiler is whining about; that variable definition
    isn't correct; try either this:

    [code=java]
    Student[] a= new Student[10];
    [/code]

    (I think that's the correct one), or try this:

    [code=java]
    StudentList[] a= new Student[10];
    [/code]

    I don't know the type StudentList, so ...

    kind regards,

    Jos

    Comment

    • max3
      New Member
      • Jul 2007
      • 13

      #3
      thanks again for your help it complied on the first part stop again under the brackets saying class interface ,or enum expected.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by max3
        thanks again for your help it complied on the first part stop again under the brackets saying class interface ,or enum expected.
        You have to show the relevant part(s) of your source then. It most likely is a
        forgotten left or right curly bracket. Check them all (most editors can do that
        for you). The compiler expects a class (or an enum since 1.5) at the top level,
        i.e. outside of any other class or enum definitions. Reading compiler diagostics
        is an accurate little activity.

        kind regards,

        Jos

        Comment

        Working...