+ 1
can enyone tell me what is mistake exactly
import java.util.Scanner; class Mycl { private int size; public void setSize(int x) { size=x; } public int getSize() { return size; } public static int weight(int x) { switch(x) { case 50 : System.out.println("weak"); break; case 70 : System.out.println("perfect"); break; case 90 : System.out.println("fat"); break; default : System.out.println("very fat"); } }
2 Answers
+ 2
method weight has no return value, missing "}" at the end, no main method, attribute size is nowhere initialized.
0
how ?? I couldn't understand that
but I have main method
public class Program {
public static void main(String[] args) {
Mycl cl =new Mycl();
System.out.print("please enter your weights");
Scanner scan =new Scanner(System.in);
cl.setSize(scan.nextInt());
System.out.println("you are :"+ cl.getSize());
}
}
and initialized size to 0
but
still not working
and I get error missing returne statement