Results 1 to 2 of 2

Thread: Assertions

  1. #1
    jayragz is offline Member
    Join Date
    Apr 2011
    Posts
    35
    Rep Power
    0

    Default Assertions

    Hey,
    I want to test the following method,

    Java Code:
    public String equateGrades(String marks){
    
     double mark = Double.parseDouble(marks);
         String[] grades = setGrades();
       
    
      for(int i =0;i<4;i++){
    
         if((mark<=100)&&(70<=mark)){
    
             grade = grades[0]+" and has a distinction";
         }
         else if((mark<=60)&&(69<=mark)){
    
             grade = grades[1]+" and has a credit";
    
         }
         else if((mark<=59)&&(50<=mark)){
    
             grade = grades[2]+" and has a pass";
    
         }
         else if((mark<=49)&&(40<=mark)){
    
             grade = grades[3]+" and has barely passed";
    
         }
         else if(mark<40){
    
             grade = grades[4]+" and has to redo his/her exams";
    
         }
      }
    
        return grade;
    }
    the grades are defined in the following method,

    Java Code:
    public String[] setGrades(){
    String[] grades = new String[5];
    
        grades[0]="A";
        grades[1]="B";
        grades[2]="C";
        grades[3]="D";
        grades[4]="E";
    
    
        return grades;
    }
    Is there an assertion that checks whether a certain mark,say 50 is equivalent to a grade of C?

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Cool

    You might like to read this : Programming With Assertions

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. Assertions
    By LovJava in forum New To Java
    Replies: 3
    Last Post: 01-07-2010, 10:13 AM
  2. Assertions on Eclipse
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 05-19-2008, 04:25 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
  •