-2

The code is

public class Multiply
{
   public static Double multiply(Double a, Double b)
   {
       return a * b
   }
}

I cannot solve the above code.
I tried a few things, like

public class Multiply 
{ 
   public double multiply(double a, double b) 
   { return a * b;} 
}

It still shows errors in code.
Kindly help, please.

R Jani
  • 21
  • 1
  • 1
  • 2

4 Answers4

3

You essentially had the answer Codewars wanted. I imagine they expected for you to just add the semicolon, as you did, but keep the rest of the code the same.

public class Multiply
{
   public static Double multiply(Double a, Double b)
   {
       return a * b;
   }
}

I went to try it out, and this worked for me. Looks like they wanted you to keep static and the wrapper class Double.

0

Here is the answer:

public class Multiply 
{ 
   public double multiply(double a, double b) 
   { return a * b;} 
}
Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
0

Think about how it will work if it is executed without any main method and what all things are missing / incorrect format in the code

E.g. Where you can add any double value

public class Multiply {
    public static double multiply(double a, double b) {
        return a * b;
    }

    public static void main(String[] args) {
        double result = multiply(20.01, 10.10);
        System.out.println("The result is: " + result);
    }
}
Brydenr
  • 798
  • 1
  • 19
  • 30
Helper
  • 1
0
public class Multiply {
public double multiply(double a , double b )
//just change the wrapper to primitive
{     
     return a*b ;
   // add semicolon over here that it 
}
Traian GEICU
  • 1,750
  • 3
  • 14
  • 26