View Single Post
  #1 (permalink)  
Old 07-16-2007, 07:27 PM
paul paul is offline
Member
 
Join Date: Jul 2007
Posts: 26
paul is on a distinguished road
How do i tell it to print out the result to the screen???
I am supposed to use an interface GradeMapper. ClassicRubric and TriageRubric are the different grading scales that i'm using to test this ability. I managed to get those 3 classes working without errors.
However once i get to the driver Class I run into a lot of problems.

Code:
public class ClassicRubric implements GradeMapper{ public String toLetter(double percent){ if (percent >= .9)return "A"; else if (percent >= .8)return "B"; else if (percent >= .7)return "C"; else if (percent >= .6)return "D"; else return "F"; } }
Code:
public class TriageRubric implements GradeMapper{ public String toLetter (double percent){ if (percent > 17.0/18.0){ return "A";} else if ((percent >8.0/9.0)){ return "A-";} else if(percent>5.0/6.0){ return "B+"; } else if(percent>7.0/9.0){ return "B"; } else if(percent>13.0/18.0){ return "B-"; } else if(percent>2.0/3.0){ return "C+"; } else if(percent>3.0/5.0){ return "C"; } else if((percent>8.0/15.0)){ return "C-"; } else if((percent>7.0/15.0)){ return "D+"; } else if(percent>2.0/5.0){ return "D"; } else if((percent>3.0)){ return "D-"; } else { return "F"; } } }
Code:
public interface GradeMapper { public String toLetter(double percent); }
i
Code:
mport java.util.Scanner; public class Driver { public static void main{ double pointsEarned; double totalPoints; int gradingType; double percent; System.out.println("input total points"); Scanner input = new Scanner(System.in); totalPoints = input.nextInt(); System.out.println("input the number of points you earned"); pointsEarned = input.nextInt(); System.out.println("For triage type 1 for classic type 2"); gradingType = input.nextInt(); percent = pointsEarned/totalPoints; if (gradingType = 1){ new TriageRubric(GradeMapper(percent)); } if (gradingType = 0){ new ClassicRubric(GradeMapper(percent)); } } }
the bolded places are where i get errors. How do i make it so that if the user enters 1 then he gets the TriageRubric that uses the "percent" variable? and if he enters 0 he gets the ClassicRubric that uses the "percent" variable.

also how do i tell it to print out the result to the screen?
Thanks
Reply With Quote
Sponsored Links