shadylookin
10-08-2006, 08:16 PM
In an attempt to get us to better understand object oriented programing 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.
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";
}
}
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";
}
}
}
package edu.bsu.cs120;
public interface GradeMapper {
public String toLetter(double percent);
}
import 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 for the help
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";
}
}
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";
}
}
}
package edu.bsu.cs120;
public interface GradeMapper {
public String toLetter(double percent);
}
import 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 for the help