but if you do:
else if ( (average == 50) && (average <=90))
that while be true just for the average identical to 50, the correct way is:
else if ( (average >= 50) && (average <=90))
Pavel
El 19/12/11 02:29, Neville Agius escribió:
else if ( (average == 50).... and not else if ( (average = 50) since
in java == is a logical operator while = is an assignment operator
Neville
On 18 December 2011 19:00, [email protected]
<mailto:[email protected]> <[email protected]
<mailto:[email protected]>> wrote:
Hello Team,
Not sure whether I post this message in the correct group, sorry.
I am trying to complete the LAB-1034 "4. (For your own exercise....),
* If the average is greater than 50 (average > 50) and less than or
equal to 90 (average <= 90), display "You did OK! Your average is xx.
0."
I have certainly made an error on using the criteria decribed on page
20 "Sample Program".
==============================
// Compute average
average = (mathGrade+historyGrade+scienceGrade)/3;
// Perform if & else control
if (average >= 60){
JOptionPane.showMessageDialog(null, "Good job! Your
average is " + average);
}
else if ( (average = 50) && (average <=90)) {
JOptionPane.showMessageDialog(null, "You did good! Your
average is " + average);
}
=============================
Any idea what's wrong?
Thanks.
Regards
Salvatore
--
You received this message because you are subscribed to the Google
Groups "JPassion.com: Java Programming" group.
To post to this group, send email to
[email protected]
<mailto:[email protected]>.
To unsubscribe from this group, send email to
[email protected]
<mailto:jpassion_java%[email protected]>.
For more options, visit this group at
http://groups.google.com/group/jpassion_java?hl=en.
--
You received this message because you are subscribed to the Google
Groups "JPassion.com: Java Programming" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jpassion_java?hl=en.
--
You received this message because you are subscribed to the Google Groups
"JPassion.com: Java Programming" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jpassion_java?hl=en.