1. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0

2. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
But you didnt incorporate the .25% that the attendance is worth

8. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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

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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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{

TextField number1Field = new TextField (3);
TextField number2Field = new TextField (3);
TextField number3Field = new TextField (3);
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);

}

public void actionPerformed(ActionEvent e){

daysMissed= 1.2* (21 - days);
finalDays= daysMissed ;

} else if (finalTask >= 80) {
} else if (finalTask >= 70) {
} else if (finalTask >= 60) {
} else {
}
outputLabel2.setText( "Attendance Points\n" + finalDays);

}

}```

14. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2010
Posts
952
Rep Power
8
Originally Posted by Ryan10
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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. Senior Member
Join Date
Mar 2011
Posts
144
Rep Power
0
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 First 1234 Last

#### Posting Permissions

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