Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Studnet Names x 10, 3 Marks and a Menu w/ adding student, deleting student, editing marks, Max Marks, Min Marks, Avearge Mark, Exit

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Studnet Names x 10, 3 Marks and a Menu w/ adding student, deleting student, editing marks, Max Marks, Min Marks, Avearge Mark, Exit

    Hi

    Can you please please help with my code??

    Thanks

    Tom

    --- Update ---

    Quote Originally Posted by MacSuibhne View Post
    Hi

    Can you please please help with my code??

    Thanks

    Tom
    *
    * SWE12075299
    * Thomas Sweeney
    * Belfast Met (Titanic Quarter)
    * JAVA Programming Level 3
    */
    package studentassignment;
    import java.util.Scanner;
    /**
     *
     * @author Tom
     */
    public class StudentAssignment {
    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
    */
     
    static void main(String[] args) 
    String [] Student  = Surname + Forename;
    int option=0, count=0;
     
    //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;
    }
     
    }


    --- Update ---

    Quote Originally Posted by MacSuibhne View Post
    Hi

    Can you please please help with my code??

    Thanks

    Tom
    Here are the errors it is compiling:

    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 = 0; i < StudentRefNo; i++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:294: class, interface, or enum expected
                for (int i = 0; i < StudentRefNo; i++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:294: class, interface, or enum expected
                for (int i = 0; i < StudentRefNo; i++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:295: class, interface, or enum expected
                    for (int j = 0; j < NameofExamination; j++) {
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:295: class, interface, or enum expected
                    for (int j = 0; j < NameofExamination; j++) {
    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-1; index=index+1)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:323: class, interface, or enum expected
    for (index=0;index<=size-1; index=index+1)
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\src\studentassignment\StudentAssignment.java:323: class, interface, or enum expected
    for (index=0;index<=size-1; index=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:915: The following error occurred while executing this line:
    C:\Users\Tom\Documents\NetBeansProjects\StudentAssignment\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 8 seconds)


  2. #2
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Studnet Names x 10, 3 Marks and a Menu w/ adding student, deleting student, editing marks, Max Marks, Min Marks, Avearge Mark, Exit

    Put it in some IDE, so you can see the errors.

Similar Threads

  1. [SOLVED] students marks coding
    By muhammad93 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 18th, 2013, 07:43 PM
  2. A program that counts the number of punctuation marks in a text file
    By Twoacross in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 21st, 2011, 04:03 PM
  3. Help! Image leaving marks
    By nivangerow in forum AWT / Java Swing
    Replies: 5
    Last Post: September 10th, 2011, 03:00 PM
  4. Replies: 5
    Last Post: August 28th, 2011, 04:48 PM
  5. Forum list improperly marks whats unread
    By Lord.Quackstar in forum The Cafe
    Replies: 14
    Last Post: June 18th, 2010, 01:14 AM