Results 1 to 2 of 2
- 07-16-2007, 05:27 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 26
- Rep Power
- 0
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.
Java 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"; } }Java 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"; } } }iJava Code:public interface GradeMapper { public String toLetter(double 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.Java 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)); } } }
also how do i tell it to print out the result to the screen?
Thanks
- 08-07-2007, 05:04 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 39
- Rep Power
- 0
You're using the assignment operator in your if statements, you should be using the comparison operator:
These statements here don't make sense to me:Java Code:gradingType == 1
What are you trying to do there? Trying to create a new instance of TriageRubric? If so, I see a few things:Java Code:new TriageRubric(GradeMapper(percent));
- The syntax is off to create a new instance
- I don't see any constructor accepting arguments
- You cannot make an instance of an interface
Greetings.
Similar Threads
-
new screen
By tha_crazy in forum New To JavaReplies: 4Last Post: 02-16-2011, 10:46 AM -
Iterating through result set in JSTL
By Java Tip in forum Java TipReplies: 0Last Post: 01-15-2008, 03:13 PM -
Iterating through result set in JSTL
By Java Tip in forum Java TipReplies: 0Last Post: 01-14-2008, 09:31 AM -
print on the client screen
By a_maged in forum NetworkingReplies: 0Last Post: 12-17-2007, 04:10 PM -
getting a random result
By gradon in forum New To JavaReplies: 2Last Post: 07-19-2007, 03:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks