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"); } }
2 Answers
+ 3
You should assign the speed like this.
m1.speed= m1.wheels*100;
m2.speed= m2.wheels*100;
0
thanks!