+ 1
Java Methods
I need to declare a method that returns double values and takes int as a parameter. e.g. static double result(int x, int y){ return x/y } for example if I put 5 and 2 as x and y, will 2.5 be returned?
2 Answers
+ 21
public class Program{
public static void main(String[] args){
double a=result(5,2); //method call
System.out.print(a);
}
static double result(int x,int y){ //method definition
return (double)x/y;
}
}
//hope it helpsâș
+ 1
Thanks it helpedđđ