Hi, to all I am new to core java . Help to solve the problem is
In my panel i created 4 textfields in that 2 of subjects fields and 2
of total and average field and 1 button . I want to calculate 2
textfields integers values and average of 2 subjects . Operands are
not working. So, please guide me regarding this topic . I written code
like this
int English =
Integer.parseInt(tfEng.getText());
int Telugu =
Integer.parseInt(tfTelugu.getText());
if(English.equals(1)||
English.equals(100)&&Telugu.equals(1)||Telugu.equals(100))
{
Total = English + Telugu;
Average = Total/2;
}
This is sample code of my program. Help me regarding this topic
Thanks
Andrew Thompson - 11 Mar 2008 13:07 GMT
...
> This is sample code of my program.
An SSCCE is a lot more descriptive than 'code snippets'.
Please consider posting a (short) compilable code in
future.
>..Help me regarding this topic
We are not your servants. A 'please' would not
go astray in that sentence.
--
Andrew T.
RedGrittyBrick - 11 Mar 2008 13:41 GMT
> Hi, to all I am new to core java . Help to solve the problem is
>
[quoted text clipped - 10 lines]
>
> if(English.equals(1)||
Your variable "English" is an int, which is a primitive type. You can't
apply methods to primitives only to reference types (i.e. objects).
Instead use
if (English == 1) ||
> English.equals(100)&&Telugu.equals(1)||Telugu.equals(100))
I'd use brackets to make the desired evaluation of this expression clearer.
> {
> Total = English + Telugu;
[quoted text clipped - 4 lines]
>
> Thanks
Lew - 12 Mar 2008 01:49 GMT
smart wrote:
>> int English =
>> Integer.parseInt(tfEng.getText());
[quoted text clipped - 8 lines]
>
> if (English == 1) ||
Two side points for the OP:
- Variable names should start with a lower-case letter: 'int english;'
- Usenet posts should be *much* less aggressively indented; two spaces is
really enough, four is the maximum.

Signature
Lew
Roedy Green - 12 Mar 2008 07:24 GMT
> Total = English + Telugu;
> Average = Total/2;
You code is hard to follow because you are ignoring coding
conventions.
see http://mindprod.com/jgloss/codingconventions.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com