Results 1 to 12 of 12
  1. #1
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default help with assignment near finished

    i am new to java i have a deadline of tomorrow i have completed my JFrame assignment 2 with no problems i have trawled google and online tutorials for assignment1 i have give it my best go i was in hospital for 4wks and was let in to level3 without level2 because i done vb last year . The assignment is a menu system for student and marks with 8 methods ive 4 done adding, removing and deleting i know for deleting ive to swap elements and unbelievably the alphabetical sort is the other which i can do easy but its the way ive set the program could someone PLEASE HELP if i post my code i want to continue with programming .

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Don't post all your code. Chances are that nobody will read it.

    Do you have a specific problem? Then post the relevant code or a SSCCE and ask a specific question.

  3. #3
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default

    how can i modify my arrays student ,mark( multidimensional array ) of 3 marks for each student and how do i swap 8 elements in a loop to delete a student and their marks thanks

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    For starters I wouldn't be using a multidimensional array. I would use a 1D array of Student objects.

  5. #5
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default

    it asks for a multidimensional array for marks how do i put that into a student object thanks

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    How about you actually post your assignment so we can see what you need to do instead of us guessing. A lot of the time people ask for help on how do X when in reality they need to do Y.

  7. #7
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default

    PROBLEM 1 :A Java program is required to perform the following processing :

    (a) input a maximum of 10 students and their corresponding marks, each consisting of :
    (i) Student Surname & Forename (surname, forename)
    stored in one String variable
    (ii) Three exam marks in integer format
    (iii) Store the above data in arrays,
    (1 array for the student name and a multi-dimensional array for the marks)

    (b) Provide a menu system to:
    • add a student (and corresponding marks) to the arrays
    • modify the details of an existing student
    • delete an existing student
    • sort the list in alphabetical order of name
    • output the list in descending/ascending order
    • display the student with the max score (sum of marks/3)
    • display the student with the min score (sum of marks/3)
    • display the average score of all students recorded (sum of marks/students)
    • exit the program

    thanks for the help

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    This assignment is cruel and unusual punishment. As stated above it would be so much simpler using a single array of objects. Using parallel arrays is a nightmare. Why is it a nightmare?

    Whatever changes (add, delete, move) in one array you hjave to make the same change in the other array to ensure the data remains matched.

    One thing you have to remember is that a 2D array is just a 1D array of arrays. Take a look at the following code example, especially the bit between the calls to print.
    Java Code:
    class Test {
        static final int SIZE = 5;
    
        public static void main(String[] args) throws Exception {
            int[][] matrix = new int[SIZE][SIZE];
            int counter = 1;
            for(int row = 0; row < SIZE; row++) {
                for(int col = 0; col < SIZE; col++) {
                    matrix[row][col] = counter++;
                }
            }
            print(matrix);
            int[] temp = matrix[0];
            matrix[0] = matrix[1];
            matrix[1] = temp;
            print(matrix);
        }
    
        public static void print(int[][] arr) {
            for(int row = 0; row < SIZE; row++) {
                for(int col = 0; col < SIZE; col++) {
                    System.out.print(arr[row][col] + " ");
                }
                System.out.println();
            }
            System.out.println();
        }        
    }

  9. #9
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default

    a bit confused i think your looping the values to increase each element by 1 i know this sort of what im stuck on but cant put it together i know your swapping elements but could you put it slightly simpler

  10. #10
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    Quote Originally Posted by Junky View Post
    This assignment is cruel and unusual punishment.
    Worse, learning to program this way will put you about 40 years behind the times! I'd find a new teacher.
    Get in the habit of using standard Java naming conventions!

  11. #11
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    I don't know how much simpler I can put it. You can ignore the first bit of code, that is just creating the 2D array and filling it with values. The important bit is how to swap values about. If you run the code and look at the output you will see that it has swapped the first row (1,2,3,4,5) with the second row (6,7,8,9,10).

  12. #12
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Quote Originally Posted by kjkrum View Post
    I'd find a new teacher.
    Unfortunately it seems that the most common order for teaching is arrays before objects. Therefore teachers set assignments to work with arrays before students know anything about objects. However they could still come up with better assignments that the ones we usually see on the fora.

Similar Threads

  1. Need help almost finished problem thats due
    By tm02943 in forum New To Java
    Replies: 2
    Last Post: 03-22-2011, 08:10 AM
  2. How do I know that byte of stream is finished?
    By mani_minhaj in forum New To Java
    Replies: 2
    Last Post: 02-26-2010, 12:08 PM
  3. Finished Product: What now?
    By Unome in forum Java Applets
    Replies: 5
    Last Post: 02-11-2009, 10:41 AM
  4. How to construct my finished program?
    By matpj in forum New To Java
    Replies: 0
    Last Post: 01-14-2009, 05:37 PM
  5. finished paint!
    By diggitydoggz in forum New To Java
    Replies: 3
    Last Post: 01-04-2009, 10:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •