Results 21 to 40 of 64
Thread: Really Quick question
 03012011, 10:07 PM #21Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
 03012011, 10:11 PM #22Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
 03012011, 10:14 PM #23Senior 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.!
 03012011, 10:18 PM #24Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
 03012011, 10:20 PM #25Senior 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.
 03012011, 10:27 PM #26Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
 03012011, 10:30 PM #27Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
But you didnt incorporate the .25% that the attendance is worth
 03012011, 10:38 PM #28Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
 03012011, 10:41 PM #29Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
so if i do what you told me 1.2* (21num5) say i use 1 it comes out to 24.2 when in the example i showed you it comes out to 23.8.
 03012011, 10:43 PM #30Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
 03012011, 10:46 PM #31Senior 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
 03012011, 10:49 PM #32Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
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
 03012011, 10:53 PM #33Senior 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{ 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); } }
 03012011, 11:08 PM #34Senior 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
 03012011, 11:24 PM #35Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
Clean up your indenting. I imagine you meant to do:
Java Code:days = Double.parseDouble(number5Field.getText());
Java Code:daysMissed= 1.2* (21  days); finalDays= daysMissed ;
Java Code:[COLOR="Blue"] double attendancePoints = 1.2 * (21  days); [/COLOR]
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] ... }
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;
Gary
 03012011, 11:36 PM #36Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
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;
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;
Gary
 03012011, 11:46 PM #37Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
Java Code:double attendancePoints = 1.2 * (TOTAL_DAYS  daysMissed)
 03012011, 11:50 PM #38Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 5
 03012011, 11:53 PM #39Senior 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; 03012011 at 11:56 PM.
 03022011, 12:18 AM #40Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
Similar Threads

Quick question
By Thumper in forum New To JavaReplies: 10Last Post: 11072010, 11:06 PM 
Quick Question...
By FatalSylence in forum New To JavaReplies: 4Last Post: 10152010, 03:38 PM 
quick question
By vouslavous in forum Java AppletsReplies: 4Last Post: 04242009, 09:35 PM 
One last quick question
By jigglywiggly in forum New To JavaReplies: 7Last Post: 01262009, 09:53 AM 
Quick Question
By Graeme in forum New To JavaReplies: 4Last Post: 01082009, 09:01 PM
Bookmarks