xkaijinx's Profile
Reputation: 0
Apprentice
- Group:
- Active Members
- Active Posts:
- 96 (0.12 per day)
- Joined:
- 09-March 11
- Profile Views:
- 1,441
- Last Active:
Feb 05 2013 02:01 PM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Linux
- Favorite Browser:
- FireFox
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Incompatible Types: required Integer.. Found Double
Posted 16 Dec 2012
Ah I got it! I needed to add another set of parenthesis around the logic of the program.
I also had to move what finalGrade is = to below all of the if statements.
Thanks guys! -
In Topic: Incompatible Types: required Integer.. Found Double
Posted 16 Dec 2012
That makes sense, I had originally set it to 0 in order to initialize it. But now I have set each variable to show a 'null' value.
If I set it to a null value the code does not run.. It gives me this error "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException" amongst another 20 lines.
If I leave each variable as.. Integer hwGrade; than the compiler is telling me to initialize each variable.
private void formMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: jTextField1.setText("Desired Grade:"); jTextField2.setText("HW Grade:"); jTextField4.setText("Quiz Grade:"); jTextField3.setText("Midterm Grade:"); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: for the button Integer desiredGrade = null; Integer hwGrade = null; Integer quizGrade = null; Integer midGrade = null; Double finalGrade = null; finalGrade = (( (desiredGrade) - (hwGrade * .4) - (quizGrade *.1) - (midGrade * .2) )); if (!jTextField2.getText().equals("")) { //desired grade desiredGrade = Integer.parseInt(jTextField2.getText()); } if (!jTextField1.getText().equals("")) { // HW Grade hwGrade = Integer.parseInt(jTextField1.getText()); } if (!jTextField4.getText().equals("")) { // Quiz Grade quizGrade = Integer.parseInt(jTextField4.getText()); } if (!jTextField3.getText().equals("")) { // Quiz Grade midGrade = Integer.parseInt(jTextField3.getText()); } jTextField5.setText(finalGrade.toString()); // score the following //Integer val2 = Integer.parseInt(jTextField1.getText()); // HW grade //val3 = Integer.parseInt(jTextField3.getText()); // Quiz grade //val4 = Integer.parseInt(jTextField4.getText()); // midterm grade } -
In Topic: Incompatible Types: required Integer.. Found Double
Posted 16 Dec 2012
Ok, I pasted below. When I did have finalGrade set as an Integer and would work only with the input provided for the desiredGrade the program would pass the value of whatever I put into that text field.
Now that it is a double for some reason it is not. I believe the below code is unable to read the text as a double... But if it read whatever text that was typed before as an integer, I do not see why it would not do the same for a Double... I may be totally wrong, just what I've been tinkering with..
jTextField5.setText(finalGrade.toString());
private void formMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: jTextField1.setText("Desired Grade:"); jTextField2.setText("HW Grade:"); jTextField4.setText("Quiz Grade:"); jTextField3.setText("Midterm Grade:"); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: for the button Integer desiredGrade = 0; Integer hwGrade = 0; Integer quizGrade = 0; Integer midGrade = 0; Double finalGrade; finalGrade = (( (desiredGrade) - (hwGrade * .4) - (quizGrade *.1) - (midGrade * .2) )); if (!jTextField2.getText().equals("")) { //desired grade desiredGrade = Integer.parseInt(jTextField2.getText()); } if (!jTextField1.getText().equals("")) { // HW Grade hwGrade = Integer.parseInt(jTextField1.getText()); } if (!jTextField4.getText().equals("")) { // Quiz Grade quizGrade = Integer.parseInt(jTextField4.getText()); } if (!jTextField3.getText().equals("")) { // Quiz Grade midGrade = Integer.parseInt(jTextField3.getText()); } jTextField5.setText(finalGrade.toString()); // score the following -
In Topic: Incompatible Types: required Integer.. Found Double
Posted 16 Dec 2012
Ah so I had tried that which allows me to run the code without errors. But... When I put the mock grades in the result every time is 0.0.
So finalGrade comes up as 0.0 no matter what numbers I input in jTextField5 -
In Topic: Coding for a Java GUI
Posted 11 Dec 2012
PBL, I am posting here because I am trying to learn. I am not even sure as to why you even replied to my initial topic because it was of 0 help.
I recall another time where I posted on this forum and PBL replied to my topic there as well... The result was the same and you provided no help or insightful guidance/advice.
I would like to thank farrel2k, and Locke for posting though. Everyone else in this community has been very helpful, and I would like to thank you all. Thanks.
My Information
- Member Title:
- D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Location:
- NY
Contact Information
- E-mail:
- Private
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
xkaijinx has no profile comments yet. Why not say hello?