Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0

    Question Please help with my program - HELP!!!!!!!!


    Hi

    I am new to all this and would really appreciate some help with my course work. I am staring at this, I have myself in knots and I can not see what is wrong...please please help!!

    All help and feed back would be greatly appreciated and please go easy on me as I am new to all of this!!

    It is compling alot of errors!!!!

    This is what I have so far:

    Java Code:
    package Student;
    import java.util.Scanner;
    /**
     *
     * 
     */
    public class Student {
    int [] NumberofStudents = new int [10];
    int [] StudentRefNo = new int [10];
    String [] Student = new String [10];
    String [] NameofExamination = new String [3];
    int [] [] ExamMarks = new int [10] [3];
    boolean exit = false;
    /**
    * @param args the command line arguments
    */
     
    //Put menu commands here
    public static void DisplayMenu() {
    System.out.println ("    ");
    System.out.println ("    ");
    System.out.println ("                                                        ");
    System.out.println ("                        MENU                            ");
    System.out.println ("                 ==================                     ");
    System.out.println (" 1) Please add the Students Name and Marks.");
    System.out.println (" 2) Modify the details of a Student.");
    System.out.println (" 3) Delete an existing Student.");
    System.out.println (" 4) Sort the Students in alphabetical order.");
    System.out.println (" 5) List the Student Names and Marks in ascending order.");
    System.out.println (" 6) List the Student Names and Marks in descending order.");
    System.out.println (" 7) Display the Student with the highest exam marks.");
    System.out.println (" 8) Display the Student with the lowest exam marks.");
    System.out.println (" 9) Display the average score of all of the students recorded.");
    System.out.println ("10) Exit Menu!");
     
    System.out.println ("     ");
    System.out.println ("      Please enter the number 1 - 10:");
    System.out.println ("     ");
     
    }
     
    {
            int option;
            switch option;
    {
        case 1: System.out.println ("Option 1 selected");
                break;
        case 2: System.out.println ("Option 2 selected");
                break;
        case 3: System.out.println ("Option 3 selected");
                break;
        case 4: System.out.println ("Option 4 selected");
                break;
        case 5: System.out.println ("Option 5 selected");
                break;
        case 6: System.out.println ("Option 6 selected");
                break;
        case 7: System.out.println ("Option 7 selected");
                break;
        case 8: System.out.println ("Option 8 selected");
                break;
        case 9: System.out.println ("Option 9 selected");
                break;
       case 10: System.out.println ("You have Exited the menu!");
                 break;
     
       default:
           System.out.println ("Nothing selected");
     
     
    System.out.println ("Finished!");
     
    }
    static void AddStudent ();
    //Positions marks in table
     
    Scanner keyb = new Scanner (System.in);
    {
    if (Student[0].isEmpty())
    StudentRefNo [0];
    Student [0] = Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3;
    }
    else
    {
    if (Student [1].isEmpty())
    StudentRefNo [1];
    Student [1] = Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    {
    if (Student [2].isEmpty())
    StudentRefNo [2];
    Student [2]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3;
    }
    else
    {  
    if (Student [3].isEmpty())
    StudentRefNo [3];
    Student [3]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    {
    if (Student [4].isEmpty()){
    StudentRefNo [4];
    Student [4]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    {
    if (Student [5].isEmpty()){
    StudentRefNo [5];
    Student [5]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    if (Student [6].isEmpty())
    StudentRefNo [6];
    Student [6]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    {
    if (Student [7].isEmpty())
    StudentRefNo [7];
    Student [7]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    {
    if (Student [8].isEmpty())
    StudentRefNo [8];
    Student [8]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
    else
    {
    if (Student [9].isEmpty())
    StudentRefNo [9];
    Student [9]= Surname + "," + Forename;
    ExamMarks[0][0] = Exam1;
    ExamMarks[0][1] = Exam2;
    ExamMarks[0][2] = Exam3; 
    }
     
    static void AddStudents (String [] Student, int StudentRefNo)
    {
    int index;
    System.out.println ("\n\n*** Please enter the Students names *** \n\n");
    for (index=0;index<=StudentRefNo-1;index=index+1)
    {
     
        Student [index]="";
    }
     
        }
     
    }
    static void remove () {
    static void alphabetically () {
    Surname=InOut.readString ();
    Forename=InOut.readstring ();
    if ( Student [0].compareTo ( Student [9])<0)
    System.out.println ("\nThis will put Students in Alphabetical order");
    System.out.println ("\t"+ Student [0]);
     
    }
    static void ascending ();
     
         String tempName;
            if (checkIfRecordExists()) {
                System.out.println("Student Reference Number\t Name \t ExamMarks1 \t ExamMarks2 \t ExamMarks3");
                for (int i = 0; i < StudentRefNo; i++) {
                    int l = i;}
                {
                    for (int j = i + 1; j < StudentRefNo; j++)}
                {
                        if (Student[i].trim().compareToIgnoreCase(Student[j].trim()) > 0) 
                            tempName = Student[j];
                            Student[j] = Student[i];
                            Student[i] = tempName;
     
                            int[] tempMarks = ExamMarks[j];
                            ExamMarks[j] = ExamMarks[i];
                            ExamMarks[i] = tempMarks;
                        }
                    }
                    System.out.print(++l + "\t " + Student[i] + "\t ");
                    for (int k = 0; k < StudentRefNo; k++) {
                        System.out.print(ExamMarks[i][k] + "\t\t ");
                    }
                    System.out.println("");
                }
            } else {
                System.out.println("Enter record first to arrange in ascending!");
            }
     
    static void descending ();
     String tempName;{
            if (checkIfRecordExists()
                System.out.println("Student Reference Number\t Name \t ExamMarks1 \t ExamMarks2 \t ExamMarks3");
                for (int i = 0; i < StudentRefNo; i++) 
                    int l = i;
                    for (int j = i + 1; j < StudentRefNo; j++) 
                        if (Student[i].trim().compareToIgnoreCase(Student[j].trim()) < 0) {
                            tempName = Student[j];
                            Student[j] = Student[i];
                            Student[i] = tempName;
     
                            int[] tempMarks = ExamMarks[j];
                            ExamMarks[j] = ExamMarks[i];
                            ExamMarks[i] = tempMarks;
                        }
                    }
                    System.out.print(++l + "\t " + Student[i] + "\t ");
                    for (int k = 0; k < StudentRefNo; k++) {
                        System.out.print(ExamMarks[i][k] + "\t\t ");
                    }
                    System.out.println("");
                }
            } else {
                System.out.println("Enter record first to arrange in descending!");
            }
    }
    static void maxmark () {
     
            double[] averageMarks = new double[ExamMarks];
            double maxMarks = averageMarks[0];
            if (checkIfRecordExists()) {
                int[] totalMarks = new int[StudentRefNo];
                String StudentWithMaxMarks = "";
     
                for (int i = 0; i < StudentRefNo; i++) {
                    for (int j = 0; j < NameofExamination; j++) {
                        //getting sum of three subject and storing in Marks 1
                        totalMarks[i] += ExamMarks[i][j];
                    }
                    //Calculating average marks for all students
                    averageMarks[i] = (double) ((totalMarks[i]) / 3);
     
                    //Comparing avarage marks and displaying max
                    if (averageMarks[i] > maxMarks) {
                        maxMarks = averageMarks[i];
                        StudentWithMaxMarks = Student[i];
                    }
                }
                System.out.println(StudentWithMaxMarks + " has obtained max average score of:" + maxMarks);
            } else {
                System.out.println("Add record first to find the avg max score!");
            }
            return maxMarks;
     
        }
    }
    static void minmark() {
     
    if (checkIfRecordExists()) {
                double[] averageMarks = new double[StudentRefNo];
                double minMarks = averageMarks[0];//DisplayMaxRecord();
                int[] totalMarks = new int[StudentRefNo];
                String StudentWithMinMarks = "";
                for (int i = 0; i < StudentRefNo; i++) {
                    for (int j = 0; j < NameofExamination; j++) {
                        //getting sum of three subject and storing in Marks 1
                        totalMarks[i] += ExamMarks[i][j];
                    }
                    //Calculating average marks for all students
                    averageMarks[i] = (double) ((totalMarks[i]) / 3);
                    minMarks = averageMarks[0];
                    StudentWithMinMarks = Student[0];
                    //Comparing avarage marks and displaying max
                    if (averageMarks[i] < minMarks) {
                        minMarks = averageMarks[i];
                       StudentWithMinMarks = Student[i];
                    }
                }
                System.out.println(StudentWithMinMarks + " has obtained min average score of:" + minMarks);
            } else {
                System.out.println("Add record first to find the avg min score!");
            }
        }
     
    }
    static void CalculateaverageExamMarks (int [] ExamMarks, int size) {
    int index;
    double dblTotal;
    double dblCalculateaverageExamMarks;
     
    dblTotal = 0.0;
     
    for (index=0;index<=size-1; index=index+1)
    {
    // adding array value to the total
    dblTotal = dblTotal + ExamMarks [index];
     
    }// end of for loop
     
    dblCalculateaverageExamMarks = dblTotal/size;
     
    return dblCalculateaverageExamMarks;
    }
     
    }
    Last edited by Winters; June 2nd, 2013 at 08:47 AM. Reason: Added Java highlighting
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    Please use code tags when posting code, this keep the code format/indention and make it easer to read.

    You should post (copy/paste) any error messages you receive.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0

    I am new.....


    Originally Posted by MrFujin
    Please use code tags when posting code, this keep the code format/indention and make it easer to read.

    You should post (copy/paste) any error messages you receive.
    Sorry I am new to all this so I don't know how to place the code in tags and I am getting the following error messages:




    PHP Code:
    nt -f C:\\Users\\Tom\\Documents\\NetBeansProjects\\StudentAssignment clean jar
    init
    :
    deps-clean:
    Updating property fileC:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build\built-clean.properties
    Deleting directory C
    :\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build
    clean
    :
    init:
    deps-jar:
    Created dirC:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build
    Updating property file
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build\built-jar.properties
    Created dir
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build\classes
    Created dir
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build\empty
    Created dirC:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build\generated-sources\ap-source-output
    Compiling 1 source file to C
    :\Users\Tom\Documents\NetBeansProjects\StudentAssignment\build\classes
    C
    :\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:2: class, interface, or enum expected
    *
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:25';' expected
    static void main(String[] args
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:55'(' expected
            
    switch option;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:55')' expected
            
    switch option;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:56: case, default, or '}' expected
    {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:85illegal start of expression
    static void AddStudent ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:85illegal start of expression
    static void AddStudent ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:85';' expected
    static void AddStudent ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:91not a statement
    StudentRefNo 
    [0];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:97'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:100not a statement
    StudentRefNo 
    [1];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:106'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:109not a statement
    StudentRefNo 
    [2];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:115'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:118not a statement
    StudentRefNo 
    [3];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:124'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:127not a statement
    StudentRefNo 
    [4];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:136not a statement
    StudentRefNo 
    [5];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:144not a statement
    StudentRefNo 
    [6];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:150'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:153not a statement
    StudentRefNo 
    [7];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:159'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:162not a statement
    StudentRefNo 
    [8];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:168'else' without 'if'
    else
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:171not a statement
    StudentRefNo 
    [9];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:178illegal start of expression
    static void AddStudents (String [] Studentint StudentRefNo)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:178illegal start of expression
    static void AddStudents (String [] Studentint StudentRefNo)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:178';' expected
    static void AddStudents (String [] Studentint StudentRefNo)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:178: <identifierexpected
    static void AddStudents (String [] Studentint StudentRefNo)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:178not a statement
    static void AddStudents (String [] Studentint StudentRefNo)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:178';' expected
    static void AddStudents (String [] Studentint StudentRefNo)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:191illegal start of expression
    static void remove () {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:191illegal start of expression
    static void remove () {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:191';' expected
    static void remove () {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:192illegal start of expression
    static void alphabetically () {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:192illegal start of expression
    static void alphabetically () {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:192';' expected
    static void alphabetically () {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:200illegal start of expression
    static void ascending ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:200illegal start of expression
    static void ascending ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:200';' expected
    static void ascending ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:208illegal start of expression
                    
    for (int j 1StudentRefNoj++)}
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:226'else' without 'if'
            
    } else {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:230illegal start of expression
    static void descending ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:230illegal start of expression
    static void descending ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:230';' expected
    static void descending ();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:232')' expected
            
    if (checkIfRecordExists()
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:235'.class' expected
                    int l 
    i;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:235not a statement
                    int l 
    i;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:235illegal start of expression
                    int l 
    i;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:253: class, interface, or enum expected
            
    } else {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:255: class, interface, or enum expected
            
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:260: class, interface, or enum expected
            double maxMarks 
    averageMarks[0];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:261: class, interface, or enum expected
            
    if (checkIfRecordExists()) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:263: class, interface, or enum expected
                String StudentWithMaxMarks 
    "";
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:265: class, interface, or enum expected
                
    for (int i 0StudentRefNoi++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:265: class, interface, or enum expected
                
    for (int i 0StudentRefNoi++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:265: class, interface, or enum expected
                
    for (int i 0StudentRefNoi++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:266: class, interface, or enum expected
                    
    for (int j 0NameofExaminationj++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:266: class, interface, or enum expected
                    
    for (int j 0NameofExaminationj++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:269: class, interface, or enum expected
                    
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:274: class, interface, or enum expected
                    
    if (averageMarks[i] > maxMarks) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:276: class, interface, or enum expected
                        StudentWithMaxMarks 
    Student[i];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:277: class, interface, or enum expected
                    
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:280: class, interface, or enum expected
            
    } else {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:282: class, interface, or enum expected
            
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:285: class, interface, or enum expected
        
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:291: class, interface, or enum expected
                double minMarks 
    averageMarks[0];//DisplayMaxRecord();
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:292: class, interface, or enum expected
                int
    [] totalMarks = new int[StudentRefNo];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:293: class, interface, or enum expected
                String StudentWithMinMarks 
    "";
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:294: class, interface, or enum expected
                
    for (int i 0StudentRefNoi++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:294: class, interface, or enum expected
                
    for (int i 0StudentRefNoi++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:294: class, interface, or enum expected
                
    for (int i 0StudentRefNoi++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:295: class, interface, or enum expected
                    
    for (int j 0NameofExaminationj++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:295: class, interface, or enum expected
                    
    for (int j 0NameofExaminationj++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:298: class, interface, or enum expected
                    
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:301: class, interface, or enum expected
                    minMarks 
    averageMarks[0];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:302: class, interface, or enum expected
                    StudentWithMinMarks 
    Student[0];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:304: class, interface, or enum expected
                    
    if (averageMarks[i] < minMarks) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:306: class, interface, or enum expected
                       StudentWithMinMarks 
    Student[i];
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:307: class, interface, or enum expected
                    
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:310: class, interface, or enum expected
            
    } else {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:312: class, interface, or enum expected
            
    }
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:318: class, interface, or enum expected
    double dblTotal
    ;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:319: class, interface, or enum expected
    double dblCalculateaverageExamMarks
    ;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:321: class, interface, or enum expected
    dblTotal 
    0.0;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:323: class, interface, or enum expected
    for (index=0;index<=size-1index=index+1)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:323: class, interface, or enum expected
    for (index=0;index<=size-1index=index+1)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:323: class, interface, or enum expected
    for (index=0;index<=size-1index=index+1)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:328: class, interface, or enum expected
    }// end of for loop
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:332: class, interface, or enum expected
    return dblCalculateaverageExamMarks;
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:333: class, interface, or enum expected
    }
    91 errors
    C
    :\Users\Tom\Documents\NetBeansProjects\StudentAssignment\nbproject\build-impl.xml:915The following error occurred while executing this line:
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\nbproject\build-impl.xml:268Compile failedsee the compiler error output for details.
    BUILD FAILED (total time8 seconds
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    4
    Rep Power
    0
    You should take a look at this..

    tutorialspoint.com/java/java_basic_syntax.htm

    docs.oracle.com/javase/tutorial/java/concepts/
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by Gamerulf
    You should take a look at this..

    tutorialspoint.com/java/java_basic_syntax.htm

    docs.oracle.com/javase/tutorial/java/concepts/
    Emmm....don't really know what to say about that......but as useful as a chocolate teapot...but thanks for replying!! :/
  10. #6
  11. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    * The only code allowed to be outside a function are definition of the variables; take especially a look at the switch statement and where it is placed.

    * { } should be place at at the same indention, e.g. if there are four space before { then there should also be four space before }.
    * All code between { and } should be moved 4 space in.

    Try look how the last half part of your code is looking/formatted and compare it with the first half.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by MrFujin
    * The only code allowed to be outside a function are definition of the variables; take especially a look at the switch statement and where it is placed.

    * { } should be place at at the same indention, e.g. if there are four space before { then there should also be four space before }.
    * All code between { and } should be moved 4 space in.

    Try look how the last half part of your code is looking/formatted and compare it with the first half.
    Can you please help and give me an example as it is not making sense? Thanks for all your help!!
  14. #8
  15. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    Instead of having code looks like this:
    Code:
            switch option;
    {
        case 1: System.out.println ("Option 1 selected");
                break;
        case 2: System.out.println ("Option 2 selected");
                break;
        case 3: System.out.println ("Option 3 selected");
                break;
        case 4: System.out.println ("Option 4 selected");
                break;
        case 5: System.out.println ("Option 5 selected");
                break;
        case 6: System.out.println ("Option 6 selected");
                break;
        case 7: System.out.println ("Option 7 selected");
                break;
        case 8: System.out.println ("Option 8 selected");
                break;
        case 9: System.out.println ("Option 9 selected");
                break;
       case 10: System.out.println ("You have Exited the menu!");
                 break;
                 
       default:
           System.out.println ("Nothing selected");
           
     
    System.out.println ("Finished!");
     
    }
    You should have it like this:
    Code:
    		switch option;
    		{
    			case 1:	
    				System.out.println ("Option 1 selected");
    				break;
    			case 2:	
    				System.out.println ("Option 2 selected");
    				break;
    			case 3:	
    				System.out.println ("Option 3 selected");
    				break;
    			case 4: 
    				System.out.println ("Option 4 selected");
    				break;
    			case 5: 
    				System.out.println ("Option 5 selected");
    				break;
    			case 6: 
    				System.out.println ("Option 6 selected");
    				break;
    			case 7: 
    				System.out.println ("Option 7 selected");
    				break;
    			case 8: 
    				System.out.println ("Option 8 selected");
    				break;
    			case 9: 
    				System.out.println ("Option 9 selected");
    				break;
    			case 10: 
    				System.out.println ("You have Exited the menu!");
    				break;
    			default:
    				System.out.println ("Nothing selected");
    				System.out.println ("Finished!");
    		}
    further more, you have a ; instead of { at the end
    Code:
    static void AddStudent ();
    You have to find out of all {}.
    In which function do you want to have the switch?
    Where does this function start and end?
    The same with all the if-else; where does each part start and end? else should be placed after the end of an if.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0

    Changes!! DEADLINE FOR TOMORROW!!


    Originally Posted by MrFujin
    Instead of having code looks like this:
    Code:
            switch option;
    {
        case 1: System.out.println ("Option 1 selected");
                break;
        case 2: System.out.println ("Option 2 selected");
                break;
        case 3: System.out.println ("Option 3 selected");
                break;
        case 4: System.out.println ("Option 4 selected");
                break;
        case 5: System.out.println ("Option 5 selected");
                break;
        case 6: System.out.println ("Option 6 selected");
                break;
        case 7: System.out.println ("Option 7 selected");
                break;
        case 8: System.out.println ("Option 8 selected");
                break;
        case 9: System.out.println ("Option 9 selected");
                break;
       case 10: System.out.println ("You have Exited the menu!");
                 break;
                 
       default:
           System.out.println ("Nothing selected");
           
     
    System.out.println ("Finished!");
     
    }
    You should have it like this:
    Code:
    		switch option;
    		{
    			case 1:	
    				System.out.println ("Option 1 selected");
    				break;
    			case 2:	
    				System.out.println ("Option 2 selected");
    				break;
    			case 3:	
    				System.out.println ("Option 3 selected");
    				break;
    			case 4: 
    				System.out.println ("Option 4 selected");
    				break;
    			case 5: 
    				System.out.println ("Option 5 selected");
    				break;
    			case 6: 
    				System.out.println ("Option 6 selected");
    				break;
    			case 7: 
    				System.out.println ("Option 7 selected");
    				break;
    			case 8: 
    				System.out.println ("Option 8 selected");
    				break;
    			case 9: 
    				System.out.println ("Option 9 selected");
    				break;
    			case 10: 
    				System.out.println ("You have Exited the menu!");
    				break;
    			default:
    				System.out.println ("Nothing selected");
    				System.out.println ("Finished!");
    		}
    further more, you have a ; instead of { at the end
    Code:
    static void AddStudent ();
    You have to find out of all {}.
    In which function do you want to have the switch?
    Where does this function start and end?
    The same with all the if-else; where does each part start and end? else should be placed after the end of an if.
    Hi Mr Fujin

    Thanks for all your help! I am in serious trouble as the coursework is due in tomorrow I have revised my code but it still wont run. I have copied both assignments along with the error messages below.

    Please please help!!

    Assignment 1:

    Code:
    package StudentAssignment;
    import java.util.Scanner;
    
    
    public class StudentAssignment {
    Scanner input = new Scanner(System.in);
    
        int numberofSubjects = 3;
        int numberofStudents = 10;
        boolean Exit = false;
        String[] studentName = new String[numberofStudents];
        int[][] studentMarks = new int[numberofStudents][numberofSubjects];
        
        //** This displays the menu for the User using the program ** //
        
     public void ProgramMenu() {
            
    System.out.println("Please select an option from the following menu:");
            
    System.out.println("****************************MENU****************************");
    System.out.println("*                                                          *");
    System.out.println("* 1. Add a new student:                                    *");
    System.out.println("* 2. Edit an existing student:                             *");
    System.out.println("* 3. Delete an existing student:                           *");
    System.out.println("* 4. Sort the names of students alphabetically:            *");
    System.out.println("* 5. Display results in Ascending order:                   *");
    System.out.println("* 6. Display results in Descending order:                  *");
    System.out.println("* 7. Display the student with maximum mark:                *");
    System.out.println("* 8. Display the student with minimum mark:                *");
    System.out.println("* 9. Display average marks of all students:                *");
    System.out.println("* 10. Exit:                                                *");
    System.out.println("*                                                          *");
    System.out.println("************************************************************");
    
    }
        
        //** This will add the students in an array **//
     
    public void AddStudents() 
    {
    System.out.println("How many student records would you like to enter?");
    numberofSubjects = input.nextInt();
    input.nextLine();
    for (int i = 0; i < numberofStudents; i++) {
    System.out.println("Please enter the Surname and the Forename of the student:");
    studentName[i] = input.nextLine();
    System.out.println("Please input the marks of the three subjects taken:");
    for (int j = 0; j < numberofSubjects; j++) {
    studentMarks[i][j] = input.nextInt();
    }
    input.nextLine();
    }
    }
        
        //** This will enable the user to edit the student records **//
    
    public void EditStudentRecords() 
    {
    EditStudentRecords();
    if (checkIfRecordExists()) {
    System.out.println("Which student record would you like to edit?");
    int choice = input.nextInt();
    choice--;
    input.nextLine();
    System.out.println("Please enter the name of the student:");
    studentName[choice] = input.nextLine();
    System.out.println("Please enter the three marks of the student:");
    for (int j = 0; j < numberofSubjects; j++) {
    studentMarks[choice][j] = input.nextInt();
    }
    }
    if (!checkIfRecordExists()) {
    System.out.println("There are no records to edit, please add the records");
    }
    System.out.println("");
    System.out.println("");
    }
            //** This lets the user delete the record of a student **//
    
    public void DeleteStudentRecord() {
    if (checkIfRecordExists()) {
    if (checkIfRecordExists()) {
    System.out.println("Which student record would you like to delete?");
    int choice = input.nextInt();
    choice--;
    for (int i = choice; i < numberofStudents; i++) 
    {
    studentName[i] = studentName[i + 1];
    numberofStudents--;
    }
    } 
    else if (!checkIfRecordExists()) 
    {
    System.out.println("You have not entered a record to delete. Please enter a record:");
    }
    System.out.println("");
    System.out.println("");
    } 
    else 
    {
    System.out.println("Record doesn't exists. Enter record first!");
    }
    }
        //** This will display the records of the students alphabetically **//
    
    public void ShowStudentRecordsAlphabetically() 
    {
    for (int i = 0; i < numberofStudents; i++) {
    if (studentName[i] != null) {
    if (i == 0) {
    System.out.println("Student Number \t Name \t Marks1 \t Marks2 \t Marks3");
    }
    int k = i+1;
    System.out.print(k + "\t " + studentName[i] + "\t ");
    for (int j = 0; j < numberofSubjects; j++) {
    System.out.print(studentMarks[i][j] + "\t\t ");
    }
    System.out.println("");
    }
    }
    System.out.println("");
    System.out.println("");
    }
        
        //** This will display the records of the students in ascending order **//
    
    public void StudentRecordsInAscendingOrder() 
    {
    String tempName;
    if (checkIfRecordExists()) {
    System.out.println("Student Number \t Name \t Marks1 \t Marks2 \t Marks3");
    for (int i = 0; i < numberofStudents; i++) {
    int l = i;
    for (int j = i + 1; j < numberofStudents; j++) {
    if (studentName[i].trim().compareToIgnoreCase(studentName[j].trim()) > 0) 
    {
    tempName = studentName[j];
    studentName[j] = studentName[i];
    studentName[i] = tempName;
    int[] tempMarks = studentMarks[j];
    studentMarks[j] = studentMarks[i];
    studentMarks[i] = tempMarks;
    }
    }
    System.out.print(++l + "\t " + studentName[i] + "\t ");
    for (int k = 0; k < numberofSubjects; k++) 
    {
    System.out.print(studentMarks[i][k] + "\t\t ");
    }
    System.out.println("");
    }
    } 
    else 
    {
    System.out.println("Please enter the first record to arrange in ascending order");
    }
    }
        
        //** Displaying record in descending order **//
    
    public void StudentRecordsInDescendingOrder() {
    String tempName;
    if (checkIfRecordExists()) {
    System.out.println("Student Number \t Name \t Marks1 \t Marks2 \t Marks3");
    for (int i = 0; i < numberofStudents; i++) 
    {
    int l = i;      
    for (int j = i + 1; j < numberofStudents; j++) {
    if (studentName[i].trim().compareToIgnoreCase(studentName[j].trim()) < 0) 
    {
    tempName = studentName[j];
    studentName[j] = studentName[i];
    studentName[i] = tempName;            
    int[] tempMarks = studentMarks[j];
    studentMarks[j] = studentMarks[i];
    studentMarks[i] = tempMarks;
    }
    }
    System.out.print(++l + "\t " + studentName[i] + "\t ");
    for (int k = 0; k < numberofSubjects; k++) 
    {
    System.out.print(studentMarks[i][k] + "\t\t ");
    }
    System.out.println("");
    }
    } 
    else 
    {
    System.out.println("Please enter the first record to arrange in descending order");
    }
    }
       
        //** This will display the student with the maximum marks  **//
    
    public double StudentWithMaxMarks() {
    double[] averageMarks = new double[numberofStudents];
    double maxMarks = averageMarks[0];
    if (checkIfRecordExists()) {
    int[] totalMarks = new int[numberofStudents];
    String studentNameWithMaxMarks = "";
    for (int i = 0; i < numberofStudents; i++) {
    for (int j = 0; j < numberofSubjects; j++) {
        
        //** This will get the total marks of the the three subjects and will store it in Marks 1 **//
        
    totalMarks[i] += studentMarks[i][j];
    }
        //** This calculates the average marks for all students listed ** //
    
    averageMarks[i] = (double) ((totalMarks[i]) / 3);
                    
        //** This will display the student with average marks and will compare with the maximum mark **//
    
    if (averageMarks[i] > maxMarks) {
    maxMarks = averageMarks[i];
    studentNameWithMaxMarks = studentName[i];
    }
    }
    System.out.println(studentNameWithMaxMarks + " has obtained maximum average score of:" + maxMarks);
    } else 
    {          
    System.out.println("Please add the first ecord to find the average maximum score!");
    }
    return maxMarks;     
    }
        
        //** This will display the minimum marks of a student **//
    
    public void StudentWithMinMarks() {
    if (checkIfRecordExists()) {
    double[] averageMarks = new double[numberofStudents];
    double minMarks = averageMarks[0];//DisplayMaxRecord();
    int[] totalMarks = new int[numberofStudents];
    String studentNameWithMinMarks = "";
    for (int i = 0; i < numberofStudents; i++) {
    for (int j = 0; j < numberofSubjects; j++) {
        
         //** This will get the total sum of the three subjects and will store them in Marks 1 **//
        
    totalMarks[i] += studentMarks[i][j];
    }
    
         //** This will calculate the average marks of all students ** //
    
    averageMarks[i] = (double) ((totalMarks[i]) / 3);
    minMarks = averageMarks[0];
    studentNameWithMinMarks = studentName[0];
    
         //** This will display the student with average marks and will compare with the minimum mark **//
    
    if (averageMarks[i] < minMarks) {
    minMarks = averageMarks[i];
    studentNameWithMinMarks = studentName[i];
    }
    }
    System.out.println(studentNameWithMinMarks + " has obtained min average score of:" + minMarks);
    } 
    else 
    {
    System.out.println("Add record first to find the avg min score!");
    }
    }
        
        //** This will display average marks of all the students **//
        
    public void AverageMarks() {
    if (checkIfRecordExists()) {
    double[] averageMarks = new double[numberofStudents];
    int[] totalMarks = new int[numberofStudents];
    for (int i = 0; i < numberofStudents; i++) {
    for (int j = 0; j < numberofSubjects; j++) {
        
        //** This will get the total sum of the three subjects and will store them in Marks 2 **//
        
    totalMarks[i] += studentMarks[i][j];
    }
    
       //** This will calculate the average mark for every student recorded **//
    
    averageMarks[i] = (double) ((totalMarks[i]) / 3);
    System.out.println(" Average score for "+i+1+" each student is:" + averageMarks[i]);     
    }
    } 
    else 
    {
    System.out.println("Add record first to find the avg min score!");
    }
    }
        
        //** This wii check if a students record has been added **//
    
    public boolean checkIfRecordExists() {
    boolean isRecordAvailable = false;
    for (int i = 0; i < numberofStudents; i++) {
    if (studentName[i] != null) {
    isRecordAvailable = true;
    } 
    else 
    {
    isRecordAvailable = false;
    }
    }
    return isRecordAvailable;
    }
        
        //** This will Exit the menu **//
    
    public boolean Exit() {
    Exit = true;
    return Exit;
    }
        
        //** This is the main method **//
    
    public static void main(String args[]) {
    StudentAssignment obj = new StudentAssignment();
    Scanner input = new Scanner(System.in);
    
            //** int delete=0; ** //
    
    do {
    obj.ProgramMenu();
    
    obj.ShowStudentRecordsAlphabetically();
    
    int Option;
    Option = input.nextInt();
    if (Option == 1) {
    obj.AddStudents();
    } 
    else 
    if (Option == 2) 
    {
    obj.EditStudentRecords();
    } 
    else 
    if (Option == 3) 
    {
    obj.DeleteStudentRecord();
    } 
    else 
    if (Option == 4) 
    {
    obj.StudentRecordsInAscendingOrder();
    } 
    else 
    if (Option  == 5) 
    {
    obj.StudentRecordsInDescendingOrder();
    } 
    else 
    if (Option  == 6) {
        
    obj.StudentWithMaxMarks();
    
    } else 
    if (Option  == 7) {
        
    obj.StudentWithMinMarks();
    
    } else 
    if (Option == 8) {
    obj.AverageMarks();
    } 
    else 
    if (Option == 9) {
        
    obj.Exit();
    } 
    else 
    {
    obj.ProgramMenu();
    }
    } 
    while (obj.Exit != true);
    }
    }
    Assignment 1 Errors:

    Code:
    run:
    java.lang.NoClassDefFoundError: studentassignment/StudentAssignment (wrong name: StudentAssignment/StudentAssignment)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: studentassignment.StudentAssignment.  Program will exit.
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)
    Assignment 2


    Code:
    package Student;
    
    import java.util.Scanner;
    
    public class Student {
        
    Scanner input = new Scanner(System.in);
    
    private String studentSurname;
    private String studentForename;
    int examMarks = 3;
    private int []mark;
    private static String courseName;
    
    public Student (){
            
    Student.courseName = "English";
    Student.courseName = "Maths";
    Student.courseName = "Java Programming";
    
    }
        
    public Student (String Surname, String Forename, int[] marks)
    {   
    this();
    this.studentSurname = Surname;
    this.studentForename = Forename;
    {
    if(courseName!=null); 
    }
    {
    this.mark = marks;
    for (int i = 0; i < examMarks; i++); 
    this.mark[i] = mark[i];      
    this.mark = this.mark[i];
    this.mark = this.mark / examMarks;
    }
    
            
     public void StudentDetails()
     {
        
    System.out.println("The Student  " + studentSurname + " " + studentForename + " is enrolled in " + Student.courseName+ ".");
    System.out.println("");
    System.out.println("The marks in three exams are:\n");
    System.out.println("Mark1\t\t Mark2\t\t Mark3");
    for (int i = 0; i < examMarks; i++) {
    System.out.print( this.mark[i]+ "\t\t ");
    }
    System.out.println("");
    System.out.println("");
    System.out.println("The total score is " + this.mark );
    System.out.println("");
    }
     
     public String GetSurname()
     {
     return this.studentSurname;
     }
     public String GetForename()
     {
     return this.studentForename;
     }
     public int[] GetExamMarks()
     {
     return this.mark;
     }
     
    public static void menu()
    {
    System.out.println("****************************MENU****************************");
    System.out.println("*                                                          *");
    System.out.println("* 1.Please add a students Surname and Forename:            *");
    System.out.println("* 2.Delete Students details:                               *");
    System.out.println("* 3.List all Students enrolled:                            *");
    System.out.println("* 4.Locate a students details:                             *");
    System.out.println("* 5.Exit                                                   *");
    System.out.println("*                                                          *");
    System.out.println("************************************************************");  
    }
    
    public static void main (String [] args)
    {
            
    Scanner input = new Scanner(System.in);
    final int TotalNumberofStudents = 6;
    int examMarks  =3;
    int [] mark = new int[examMarks ];
    int NumberofStudents = 0;
    int intNumber, chooseCase;
    String studentSurname, studentForename;
    Student[] myClass = new Student[TotalNumberofStudents];
            
    while(1==1){
                
    menu();
    System.out.println("\n\n Please enter a number from the Menu ");
    chooseCase = input.nextInt();
                
    switch(chooseCase){
                    
    case 1:
                        
    if(NumberofStudents<TotalNumberofStudents){
    NumberofStudents = NumberofStudents + 1;
    System.out.println("Please enter the Surname of the Student:");
    input.nextLine();
    studentSurname = input.nextLine();
    System.out.println("Please enter the Forename of the Student:");
    studentForename = input.nextLine();
    System.out.println("Please enter the marks obtained in three exams:");
    for (int i = 0; i<examMarks; i++) {
    mark[i] =input.nextInt();
    }
    myClass[NumberofStudents] = new Student(studentSurname, studentForename, mark);
    }
                        
    break;
                        
    case 2:
                        
    if(NumberofStudents!=0){
    System.out.println("Which students details would you like to delete?");
    intNumber = input.nextInt();
    for (int i = intNumber; i <= NumberofStudents; i++) {
    myClass[i] = myClass[i+1];
    NumberofStudents--;
    }
    }else{
    System.out.println("There are no records to display.");
    break;
    }
        
    case 3:
    
    if(NumberofStudents!=0){
    for (int i = 1; i <= NumberofStudents; i++) {
    System.out.print(i + "\t\t" + myClass[i].GetSurname() + " " + myClass[i].GetForename());
    System.out.println("\t\t" + Student.courseName + "\t\t" + myClass[i].mark);
    }
    }else{
    System.out.println("There are no records to display.");
    
    break;
    }
                        
    case 4:
    {
    System.out.println("Please enter the name of the course");
    input.nextLine();
    courseName  = input.nextLine();
    }
    break;
                        
    case 5:
    
    if(NumberofStudents!=0){
    for (int i = 1; i <=NumberofStudents; i++) {
    System.out.println(i + "\t"+ myClass[i].studentSurname + " " + myClass[i].studentForename);
    }
    System.out.println("Which student details you want to see. Enter the corresponding number.");
    intNumber = input.nextInt();
    myClass[intNumber-1].StudentDetails();
    }else{
    System.out.println("There is no records to display:"); 
    }
    break;
    
    case 6:
    
    System.out.println("You are now exiting the menu");
    
    break;
    
    }
    }
    }
    }
    Assignment 2 Errors:

    Code:
    Compiling 1 source file to C:\Users\Tom\Documents\NetBeansProjects\Student\build\classes
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:49: illegal start of expression
     public void StudentDetails()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:49: illegal start of expression
     public void StudentDetails()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:49: ';' expected
     public void StudentDetails()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:65: illegal start of expression
     public String GetSurname()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:65: ';' expected
     public String GetSurname()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:69: illegal start of expression
     public String GetForename()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:69: ';' expected
     public String GetForename()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:73: illegal start of expression
     public int[] GetExamMarks()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:73: ';' expected
     public int[] GetExamMarks()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:78: illegal start of expression
    public static void menu()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:78: illegal start of expression
    public static void menu()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:78: ';' expected
    public static void menu()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:78: ';' expected
    public static void menu()
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:91: illegal start of expression
    public static void main (String [] args)
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:91: illegal start of expression
    public static void main (String [] args)
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:91: ';' expected
    public static void main (String [] args)
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:91: '.class' expected
    public static void main (String [] args)
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:91: ';' expected
    public static void main (String [] args)
    C:\Users\Tom\Documents\NetBeansProjects\Student\src\student\Student.java:187: reached end of file while parsing
    }
    19 errors
    C:\Users\Tom\Documents\NetBeansProjects\Student\nbproject\build-impl.xml:915: The following error occurred while executing this line:
    C:\Users\Tom\Documents\NetBeansProjects\Student\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 1 second)
    
    run:
    java.lang.NoClassDefFoundError: student/Student (wrong name: Student/Student)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: student.Student.  Program will exit.
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)
    As you can see Assignment 2 is worse but I think this due to the "this.mark" statements....assignment one is just not running but I think this is to do with simple mistakes
  18. #10
  19. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    java.lang.NoClassDefFoundError: studentassignment/StudentAssignment (wrong name: StudentAssignment/StudentAssignment)
    Java is case sensitive. Make sure the names used match. See the start of the package/classnames: stu... vs Stu...
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by NormR
    Java is case sensitive. Make sure the names used match. See the start of the package/classnames: stu... vs Stu...
    Thanks Norm. Any input on the other errors please? This is due in tomorrow!!
  22. #12
  23. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    Which statement is on line 49? The error is before that.
    The code in the Student class posted in post#9 needs to be properly formatted so it can be read and understood. The statements should NOT all start in the first column.

    Make sure the {}s are properly matched. Proper formatting will help anyone see problems.

    http://www.oracle.com/technetwork/ja...oc-136057.html
    Last edited by NormR; June 4th, 2013 at 08:24 AM.
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by NormR
    Which statement is on line 49? The error is before that.
    The code in the Student class posted in post#9 needs to be properly formatted so it can be read and understood. The statements should NOT all start in the first column.

    Make sure the {}s are properly matched. Proper formatting will help anyone see problems.

    http://www.oracle.com/technetwork/ja...oc-136057.html
    Hi Norm, again thanks for all your help!!! Can you please elaborate on the following and if possible can you give me an example??

    The statements should NOT all start in the first column.
  26. #14
  27. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    Try to re-read what I wrote in #6 and #8.

    Instead of
    Code:
    public Student (){
            
    Student.courseName = "English";
    Student.courseName = "Maths";
    Student.courseName = "Java Programming";
    
    }
    you should intend the lines with a tab or spaces:
    Code:
    public Student (){  
        Student.courseName = "English";
        Student.courseName = "Maths";
        Student.courseName = "Java Programming";
    }
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0
    There are issues with opening { and closing }. Need to have matching } for every {.

    ----------------
    Explain-Java.com
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo