I'm getting bad operantd error help :( | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm getting bad operantd error help :(

import java.util.Scanner; enum Type {EQUILATERAL, ISOSCELES, SCALENE, NOTTRIANGLE} class PossibleTriangle { private int a; private int b; private int c; private Type pt; public PossibleTriangle () { a = ' '; b = ' '; c = ' '; pt = Type.NOTTRIANGLE; } public PossibleTriangle (int a, int b, int c) { this.a = a; this.b = b; this.c = c; pt = getType (); } public PossibleTriangle (PossibleTriangle pt) { this (pt.a, pt.b, pt.c); } private boolean isTriangle () { if (a + b > c && b + c > a && c + a > b && a >= 1 && b >= 1 && c >= 1) return true; else return false; } private Type getType () { if (isTriangle () && (a = b) && (b = c) && (c = a)) return Type.EQUILATERAL; else if ((isTriangle () & (a = b))) return Type.ISOSCELES; else if ((isTriangle () & (a != b != c))) return Type.SCALENE; else return Type.NOTTRIANGLE; } im getting bad operand error on && for first two of the lines and boolean and int error on != private Type getType () { if (isTriangle () && (a = b) && (b = c) && (c = a)) return Type.EQUILATERAL; else if ((isTriangle () & (a = b))) return Type.ISOSCELES; else if ((isTriangle () & (a != b != c))) return Type.SCALENE; else return Type.NOTTRIANGLE; }

5th Feb 2020, 8:00 AM
roy kingston
roy kingston - avatar
3 Answers
+ 3
If you need help, you can post the code you're struggling with! Follow this post 👇👇👇 https://www.sololearn.com/post/75089/?ref=app
5th Feb 2020, 8:54 AM
Scooby
Scooby - avatar
+ 1
Can you write this program on Sololearn Playground?
5th Feb 2020, 8:27 AM
A͢J
A͢J - avatar
+ 1
a=b here = assigning operator, You should use ==, comparition operator. a==b. (a!=b!= c)=> b!=c will result boolean value which is not compatible with a int type.. You may looking for this may be (a! =b) && (a! =c). And as other said, it it better to share the code by copying to playground.. So make these changes, and further help share your code link... Then you get better help from some one
5th Feb 2020, 9:23 AM
Jayakrishna 🇮🇳