Results 1 to 20 of 64
Thread: Really Quick question
 03012011, 06:48 PM #1Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
Class Calculator Help
Im making a simple calculator in java and i have two things that i am stuck on but can't quite figure out the math part of it. I have to : Create an input for Attendance 25% of your overall grade  (1.2 points each day) and also create an input box for Labs 25% of your overall grade.  1.4 points each Lab total of 18 Labs. The other 50% i already figured out which was entering in 4 test grades and it works fine. Any help would be much appreciated. Thanks
Last edited by Ryan10; 03012011 at 07:06 PM.

I see partial program requirements posted above but no actual specific question. So in that vein, what is your specific question? Also, you're far better off using a thread title here that has some bearing on your problem. All new threads here are questions, and I see nothing "quick" about yours. If it were mine, I'd change it to "How to implement class calculator" or something along those lines.
 03012011, 07:01 PM #3Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
Java Code:import java.applet.*; import java.awt.*; import java.awt.event.*; import java.awt.Color.*; public class task2 extends Applet implements ActionListener{ Double num1, num2, num3, num4, num5, answer, answer2, total, total2, average; char grade; Label titleLabel = new Label("Enter your grades for each of your assignments below: \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); Button goButton = new Button("GO \n"); Label outputLabel = new Label ("\nYour Grade. \n"); Label outputLabel2 = new Label ("\nNumber Grade is \n"); Label outputLabel3 = new Label ("\nParticipation \n"); Label outputLabel4 = new Label ("\nAverage \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(goButton); goButton.addActionListener(this); add(outputLabel); add(outputLabel2); add(outputLabel3); add(outputLabel4); } public void actionPerformed(ActionEvent e){ num1 = Double.parseDouble(number1Field.getText()); num2 = Double.parseDouble(number2Field.getText()); num3 = Double.parseDouble(number3Field.getText()); num4 = Double.parseDouble(number4Field.getText()); num5 = Double.parseDouble(number5Field.getText()); answer= num1 + num2 + num3 + num4; total= answer /4 * 1/2; answer2= num5 * 12/10; total2= answer * 1/4; average = total +total2; outputLabel.setText("total" + Math.round(total)); if (total >= 90) { grade = 'A'; } else if (total >= 80) { grade = 'B'; } else if (total >= 70) { grade = 'C'; } else if (total >= 60) { grade = 'D'; } else { grade = 'F'; } outputLabel.setText("Grade:\n" + grade); outputLabel2.setText("Numeric Grade \n" + total); outputLabel3.setText ("Participation: \n" + total2); outputLabel4.setText ("Final Grade \n" + average); } }
I have the 50% grade part all figured out now i just have to figure out the assignment and lab part out. The math part i put in my first post. The math part is what i need help on. ThanksLast edited by Ryan10; 03012011 at 07:04 PM.
 03012011, 08:45 PM #4Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
can anyone here help me out with this?
 03012011, 09:02 PM #5Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
I agree with Fubarable that "Really Quick question" is a very poor title for this thread. Names are important, and choosing good names is a skill you should try to acquire early. Your class should not be called task2. I wouldn't complain about Task2 (notice the capital letter), but something like GradeCalculator is better. Your other variables have similarly vague names.
You should use arrays rather than discrete variables for things that are similar, such as your TextFields, your test scores, and your lab scores. I don't see anything in your program yet to keep track of the 18 labs that are supposed to be worth 1.4 points each. It's not clear whether the labs are to be graded or simply full points awarded for each lab completed. I can guess that attendance is 21 days (18 * 1.4 = 21 * 1.2). That means that labs and attendance together can earn a total of 50.4 points, which is supposed to represent 50% of the grade, which implies that the other 50%, average test score, is also worth 50.4 points.
Anyway, it seems like the math is essentially this:
Java Code:finalGrade = 50.4 * (testAverage/100) + 1.2 * (21  daysMissed) + 1.4 * labsCompleted; // or maybe 1.4 * (totalLabScore / 1800) assuming each lab is scored 0100
Gary
 03012011, 09:08 PM #6Senior Member
 Join Date
 Feb 2011
 Posts
 118
 Rep Power
 0
 03012011, 09:13 PM #7Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
so your saying daysMissed and labsCompleted should be set as integers aswell as testAverage
 03012011, 09:17 PM #8Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
 03012011, 09:19 PM #9Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
Here's an example that someone else did and we can use it as a guide maybe it will give you a clearer picture of what im trying to do.
http://plourde.smccme.edu/GPAapplet.html
 03012011, 09:25 PM #10Senior Member
 Join Date
 Feb 2011
 Posts
 118
 Rep Power
 0
 03012011, 09:25 PM #11Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
 03012011, 09:27 PM #12Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
I still havent figured out what the math part is for those two examples..i know the other 50% if we start changing things around i have to change the integers because thats how i set it up.
 03012011, 09:30 PM #13Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
 03012011, 09:34 PM #14Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
I changed that..didn't really know it made a difference. Instead of making it all one string for the final grade i was trying to do them separate then add all of them up at the end to get the final grade. Do you know what i mean. Lets take it one by one if i were to do the math for the attendance/participation grade how would i go about doing so?
Last edited by Ryan10; 03012011 at 09:36 PM.
 03012011, 09:39 PM #15Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
 03012011, 09:43 PM #16Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
 03012011, 09:43 PM #17Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
Thats why im asking for help on here because what math am i supposed to use for attendance if its 1.2 points each day missed and 25% of my overall grade? I know that the 1.2 has to deduct of the grade i just need a push in the right direction. Remember im a noob at this stuff sorry.
 03012011, 09:52 PM #18Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
I don't read it as 1.2 points each day missed, but 1.2 points each day attended.
Look at it this way: there are 18 Labs, right? Each one is worth 1.4 points, right? That means if you complete all 18, you get 25.2 points, right? And Labs are worth 25% of your grade, right?
Attendance is also worth 25%, same as labs, right? That means Attendance must also be worth 25.2 points, just as Labs are. 25.2 divided by 1.2 points per day means 21 total days, right?
So 25.2 points for Labs and 25.2 points for Attendance makes 50.4 points. And that's 50% of your grade, right? So test scores must also be 50.4 points.
So you'll compute a score for attendance (max 25.2) a score for labs (max 25.2) and a score for test average (max 50.4), and then add them all together (max 100.8), right?
Tell me if you understand that much, and then go from there.
Gary
 03012011, 09:57 PM #19Senior Member
 Join Date
 Mar 2011
 Posts
 144
 Rep Power
 0
so 1.2* (21daysMissed meaning what the user types in) the thing i don't understand is what are we supposed to put for days missed. Is it just a variable and yes i see how you get the math its correct. This is what i have so far daysMissed= 1.2*(21num5) ... 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.
Last edited by Ryan10; 03012011 at 10:00 PM.
 03012011, 09:59 PM #20Senior Member
 Join Date
 Mar 2010
 Posts
 952
 Rep Power
 6
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, 02:38 PM 
quick question
By vouslavous in forum Java AppletsReplies: 4Last Post: 04242009, 08: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