Results 1 to 2 of 2
  1. #1
    theseven is offline Member
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

    Post How to use Switch case A, B C, D, E,F mark change to 5,4,3,2,1,0 mark java

    problem:

    Marks are recorded using the six-letter grade system.
     When calculation of the average mark is needed, the letter grades are first converted into numeric values as follows: A to 5, B to 4, C to 3, D to 2, E to 1, F to 0. Then the average of the numeric values are calculated and displayed.
    Record the following:
     The time required to re-implement the above changes.
     The number of functions needed to be changed.
     The number of lines of code needed to be changed



    java code:
    public class Main_2 {

    static String[] deptCode = {"HRO", "FIN", "IT", "SALES"};
    static String[] employeeID = {"1", "2", "3", "4", "5", "6", "7", "8"};
    static char[][] marks = { {'F', 'D', 'C', 'B', 'C', 'B', 'C', 'A'}, // mark for HRO
    {'D', 'B', 'A', 'A', 'F', 'B', 'C', 'C'}, // mark for FIN
    {'D', 'B', 'E', 'B', 'C', 'F', 'F', 'D'}, // mark for IT
    {'C', 'B', 'E', 'D', 'C', 'B', 'C', 'A'} }; // mark for SALES

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {


    // TODO code application logic here
    int deptID = -1;


    for (int i = 0; i < deptCode.length; i++) {
    if (args[1].equals(deptCode[i])) {
    deptID = i; ////// ******* //////
    break;
    }
    }
    double sum=0;
    int maxID=0;
    int nEmployee=employeeID.length;
    for (int i=0; i < nEmployee; i++ ){
    sum+=marks[deptID][i]; // add up all the marks for the department
    if(marks[deptID][maxID]<marks[deptID][i]) maxID=i; // find student who has maximum
    }
    sum/=nEmployee; // calculate average
    System.out.println("HRO: Average performance = " + sum); // output average
    System.out.println("Max mark belongs to studentID = "+ maxID); // output max mark

    }


    }
    Last edited by theseven; 02-13-2010 at 01:12 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Hello and welcome to the forum. I've locked the duplicate thread. I suggest that you edit your post and add code tags (see my signature below) to help make your posted code readable. You also might want to add some text describing your problem in greater detail. Anything you can do to make it easier for others to help you will increase your chances of getting help. Much luck!

Similar Threads

  1. Java Tactics - Mark Bourne
    By markbourne in forum Reviews / Advertising
    Replies: 1
    Last Post: 10-23-2008, 02:47 AM
  2. Java Tactics Book By Mark Bourne
    By markbourne in forum Java Certification
    Replies: 0
    Last Post: 07-07-2008, 10:47 PM
  3. Mark thread RESOLVED.
    By Eranga in forum Suggestions & Feedback
    Replies: 45
    Last Post: 04-02-2008, 10:34 AM
  4. how to draw an arrow mark using java swing
    By sandhyau in forum AWT / Swing
    Replies: 5
    Last Post: 02-07-2008, 11:52 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
  •