+ 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"); } }

28th Oct 2017, 11:12 PM
Asmaa Mogahed Khalifa Osman
Asmaa Mogahed Khalifa Osman - avatar
2 Respostas
+ 2
method weight has no return value, missing "}" at the end, no main method, attribute size is nowhere initialized.
28th Oct 2017, 11:21 PM
Jeremy
Jeremy - avatar
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
29th Oct 2017, 9:10 AM
Asmaa Mogahed Khalifa Osman
Asmaa Mogahed Khalifa Osman - avatar