Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 64
  1. #21
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

  2. #22
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    This is what i have so far daysMissed= 1.2*(21-num5) ... finalDays= daysMissed * 1/4 (meaning for 25%) so if i type in 0 days missed i should get 25 points. I get 6.3 for an answer clearly something is wrong.
    You didn't get this from me. I completely agree that 25.2 * 1/4 = 6.3, but I don't see how that's helpful for you.

    -Gary-

  3. #23
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    well if i do 1.2 * daysMissed -25 it comes out as -23.8 but its supposed to be positive 23.8. Wow i must suck at math or theres something im missing here.!

  4. #24
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    well if i do 1.2 * daysMissed -25 it comes out as -23.8 but its supposed to be positive 23.8. Wow i must suck at math or theres something im missing here.!
    Well, you're not demonstrating much facility with math today anyway. Your version of daysMissed is num5 (not a great name, but that's what you have). You already had 1.2 * (21 - num5). Why do you want anything different?

    -Gary-

  5. #25
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    daysMissed= days * 1.2 (i changed the name)
    finalDays= daysMissed + 100 / 1/4 - 1.2

    The answer comes out to 25 points if i type in 0 days missed and if i type in 1 day it comes to 23.8 but if i put in another number it stays at 23.8.

  6. #26
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    daysMissed= days * 1.2 (i changed the name)
    finalDays= daysMissed + 100 / 1/4 - 1.2

    The answer comes out to 25 points if i type in 0 days missed and if i type in 1 day it comes to 23.8 but if i put in another number it stays at 23.8.
    OK, I give up. You are not making any sense at all now. The answers are all there in the thread already. Take a break, then come back and take a fresh look at this.

    -Gary-

  7. #27
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    But you didnt incorporate the .25% that the attendance is worth

  8. #28
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    But you didnt incorporate the .25% that the attendance is worth
    25.2 points for attendance + 25.2 points for labs + 50.4 points for tests = 100.8 points. Do you want to compute points or percentages? If you really want to scale this as a percentage (I'm not at all convinced that you do), then the proper factor is 100/100.8.

    -Gary-

  9. #29
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    so if i do what you told me 1.2* (21-num5) say i use 1 it comes out to 24.2 when in the example i showed you it comes out to 23.8.

  10. #30
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    so if i do what you told me 1.2* (21-num5) say i use 1 it comes out to 24.2 when in the example i showed you it comes out to 23.8.
    24.2 is correct for missing one day (20 days at 1.2 points per day). 23.8 is a meaningless number you got by throwing garbage at the wall to see what stuck to it (it's 25 - 1.2 but that is of no consequence in what you're trying to do).

    -Gary-

  11. #31
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Well i got that to show up (YAY) but if i type in like 2 days missed or 3 days missed it just stays as the same answer

  12. #32
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    Well i got that to show up (YAY) but if i type in like 2 days missed or 3 days missed it just stays as the same answer
    Show your code.

    By the way, my interpretation of the assignment is based on what you've told me. You saw how I got to 25.2 points labs, 25.2 points attendance, 50.4 points tests. You're the one getting graded on this, so if you think it should be 25 points labs, 25 points attendance and 50 points tests, you should code it that way.

    -Gary-

  13. #33
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Well it is supposed to be 25,25,50 but i dont know how you would code it when you type in 0 days missed it should show 25 points towards attendance..miss 1 day it should show 23.8 and so on. This is my code so far:

    Java Code:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Color.*;
    
    public class practice extends Applet implements ActionListener{
    
    
    
    	double task1, task2, task3, task4, task5, days, finalTask, daysMissed, finalDays, testAverage;
    	char grade;
    
    		Label titleLabel = new Label("Tasks are 50% of your overall grade: \n");
    		Label number1Label = new Label ("Enter First Task Grade: \n");
    			TextField number1Field = new TextField (3);
    		Label number2Label = new Label ("Enter Second Task Grade: \n");
    			TextField number2Field = new TextField (3);
    		Label number3Label = new Label ("\nEnter Third Task Grade: \n");
    			TextField number3Field = new TextField (3);
    		Label number4Label = new Label ("\nEnter Forth Task Grade: \n");
    			TextField number4Field = new TextField (3);
    		Label number5Label = new Label ("\nHow many Days did you miss: \n");
    			TextField number5Field = new TextField (3);
    		Label number6Label = new Label ("\n\n\nLabs completed out of 18 \n");
    			TextField number6Field = new TextField (3);
    		Button goButton = new Button("GO \n");
    		Label outputLabel = new Label ("\nTask Points.      \n");
    		Label outputLabel2 = new Label ("\nDays Missed   \n");
    
    
    
    
    
    		public void init() {
    			setForeground(Color.blue);
    			add(titleLabel);
    			add(number1Label);
    			add(number1Field);
    			add(number2Label);
    			add(number2Field);
    			add(number3Label);
    			add(number3Field);
    			add(number4Label);
    			add(number4Field);
    			add(number5Label);
    			add(number5Field);
    			add(number6Field);
    			add(number6Label);
    			add(goButton);
    			goButton.addActionListener(this);
    			add(outputLabel);
    			add(outputLabel2);
    
    
    	}
    
    	public void actionPerformed(ActionEvent e){
    
    	task1= Double.parseDouble(number1Field.getText());
    	task2= Double.parseDouble(number2Field.getText());
    	task3= Double.parseDouble(number3Field.getText());
    	task4= Double.parseDouble(number4Field.getText());
    
    
    
    
    
    testAverage= task1 + task2 + task3 +task4;
    finalTask= testAverage /4 * 1/2;
    
    daysMissed= 1.2* (21 - days);
    finalDays= daysMissed ;
    
    
    
    	outputLabel.setText("total" + Math.round(finalTask));
    
    
    
    
    
    		if (finalTask >= 90) {
    			grade = 'A';
    		} else if (finalTask >= 80) {
    			grade = 'B';
    		} else if (finalTask >= 70) {
    			grade = 'C';
    		} else if (finalTask >= 60) {
    			grade = 'D';
    		} else {
    			grade = 'F';
    		}
    		outputLabel.setText("Task Points:\n"   + finalTask);
    		outputLabel2.setText( "Attendance Points\n" + finalDays);
    
    
    
    
    
    	}
    
    }

  14. #34
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    You still there..can you figure it out if not i will just move onto the labs which is 1.4 points also 25% of the grade

  15. #35
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Clean up your indenting. I imagine you meant to do:
    Java Code:
    	days = Double.parseDouble(number5Field.getText());
    somewhere, but I don't see it. This:
    Java Code:
    daysMissed= 1.2* (21 - days);
    finalDays= daysMissed ;
    ...makes no sense. What the user enters in the field is daysMissed, right? That's what you're asking them: How many Days did you miss: after all. You've changed the initial variable from num5 to days but it still represents the number of days missed. This is better:
    Java Code:
    [COLOR="Blue"]        double attendancePoints = 1.2 * (21 - days);
    [/COLOR]
    And this is better yet:
    Java Code:
    public class practice extends Applet implements ActionListener{
    [COLOR="blue"]    private static final double TOTAL_DAYS = 21;
    [/COLOR]    ...
        public void actionPerformed(ActionEvent e) {
            ...
    [COLOR="blue"]	double daysMissed = Double.parseDouble(number5Field.getText());
    [/COLOR]        ...
    [COLOR="blue"]        double attendancePoints = 1.2 * (TOTAL_DAYS - daysMissed)
    [/COLOR]        ...
        }
    Like I said before, names matter. If you choose vague or confusing or wrong names, your code won't make sense.

    If you're working from a total of 25 points for attendance, 25 points for labs, and 50 points for tests, then of course your math should be different.
    Java Code:
            double attendancePoints = 25 - 1.2 * daysMissed;
            double labPoints = 25 - 1.4 * (18 - labsCompleted);
            double testPoints = 50 * testAverage / 100;
            double totalPoints = attendancePoints + labPoints + testPoints;
    You should have said so in the first place.

    -Gary-

  16. #36
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    In case it wasn't clear from my previous post, it's generally bad style to have "magic numbers" in the middle of your code. If there are values that are dictated by circumstance, it's much better to declare them as constants at the top of your class:
    Java Code:
    public class practice extends Applet implements ActionListener{
        private static final double TOTAL_DAYS = 21;
        private static final double MAX_ATTENDANCE_POINTS = 25;
        private static final double MISSED_DAY_PENALTY = 1.2;
        private static final double TOTAL_LABS = 18;
        private static final double MAX_LAB_POINTS = 25;
        private static final double MISSED_LAB_PENALTY = 1.4;
        private static final double MAX_TEST_POINTS = 50;
    Then use those constants in your code:
    Java Code:
            double attendancePoints = MAX_ATTENDANCE_POINTS - MISSED_DAY_PENALTY * daysMissed;
            double labPoints = MAX_LAB_POINTS - MISSED_LAB_PENALTY * (TOTAL_LABS - labsCompleted);
            double testPoints = MAX_TEST_POINTS * testAverage / 100; // testAverage is a percentage, so divide by 100
            double totalPoints = attendancePoints + labPoints + testPoints;
    Using constants makes it clear to whoever's reading the code (including you, when you come back to it weeks, months or years from now) what these values mean. Declaring them at the top of your class makes it easy to change them when conditions change.

    -Gary-

  17. #37
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Java Code:
    double attendancePoints = 1.2 * (TOTAL_DAYS - daysMissed)
    Where exactly am i supposed to put this and do i "really" need double in front of it because im getting an error

  18. #38
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by Ryan10 View Post
    Java Code:
    double attendancePoints = 1.2 * (TOTAL_DAYS - daysMissed)
    Where exactly am i supposed to put this and do i "really" need double in front of it because im getting an error
    This is really too much. You're supposed to be the one writing the code. I'm not going to tell you exactly where to put it. It's an illustration. Do your homework.

    -Gary-

  19. #39
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Im working on it now stay tuned to see if i get it. I get the attendance points and task points to work but the lab points doesn't work it comes out as a negative number. I can show you my code as of now to see it just let me know. Thanks for everything so far.
    Last edited by Ryan10; 03-01-2011 at 11:56 PM.

  20. #40
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Ok im making progress so far i got all the grades to work now i need to figure out the letter grade. It's not adding up right..any last help calvin
    Last edited by Ryan10; 03-02-2011 at 12:29 AM.

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Quick question
    By Thumper in forum New To Java
    Replies: 10
    Last Post: 11-07-2010, 11:06 PM
  2. Quick Question...
    By FatalSylence in forum New To Java
    Replies: 4
    Last Post: 10-15-2010, 03:38 PM
  3. quick question
    By vouslavous in forum Java Applets
    Replies: 4
    Last Post: 04-24-2009, 09:35 PM
  4. One last quick question
    By jigglywiggly in forum New To Java
    Replies: 7
    Last Post: 01-26-2009, 09:53 AM
  5. Quick Question
    By Graeme in forum New To Java
    Replies: 4
    Last Post: 01-08-2009, 09:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •