0

whats wrong with this code??

public class mashin{ int wheels; int speed; String type; String pl(){ if(speed<200){ type="slow"; } else if(speed<=300){ type="fast"; } else if(speed>300){ type="furios"; } return type; } } class myclass{ public static void main(String[] args){ mashin m1=new mashin(); mashin m2=new mashin(); m1.wheels=3; m2.wheels=1; speed= wheels*100; System.out.println(m1.pl()+"m1"); System.out.println(m2.pl()+"m2"); } }

8th Oct 2020, 2:21 PM
Alireza Khobi
Alireza Khobi - avatar
2 Réponses
+ 3
You should assign the speed like this. m1.speed= m1.wheels*100; m2.speed= m2.wheels*100;
8th Oct 2020, 2:30 PM
Avinesh
Avinesh - avatar
0
thanks!
8th Oct 2020, 2:35 PM
Alireza Khobi
Alireza Khobi - avatar