Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2007, 06:27 PM
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 06:04 AM
Member
 
Join Date: Jul 2007
Posts: 39
coco is on a distinguished road
You're using the assignment operator in your if statements, you should be using the comparison operator:
Code:
gradingType == 1
These statements here don't make sense to me:
Code:
new TriageRubric(GradeMapper(percent));
What are you trying to do there? Trying to create a new instance of TriageRubric? If so, I see a few things:
  1. The syntax is off to create a new instance
  2. I don't see any constructor accepting arguments
  3. You cannot make an instance of an interface
Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterating through result set in JSTL Java Tip Java Tips 0 01-15-2008 04:13 PM
Iterating through result set in JSTL Java Tip Java Tips 0 01-14-2008 10:31 AM
print on the client screen a_maged Networking 0 12-17-2007 05:10 PM
new screen tha_crazy New To Java 2 08-15-2007 10:30 AM
getting a random result gradon New To Java 2 07-19-2007 04:54 PM


All times are GMT +3. The time now is 09:58 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org