Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with my first Java program

Tags:

java

I'm trying to make a simple pounds to kilogram converter. Not sure what I'm doing wrong because it won't print out the answer. Could someone help me out.

public class ass10 {

    public static void main(String[] args) {
    double lbs2kg(3);
    }
    public double lbs2kg(double w){
        System.out.println(w/2.2);
    }
}
like image 954
user1730056 Avatar asked Jul 11 '26 11:07

user1730056


1 Answers

Delete double or put a variable and also method lbs2kg() must be static (Make it return double or a compatible type, too).

public static void main(String[] args) {
    double x = lbs2kg(3);
}
like image 54
Juvanis Avatar answered Jul 15 '26 03:07

Juvanis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!