i got WA on this problem at running 10th
here is my code:
import java.util.Scanner;
import java.io.PrintStream;
public class Main{
public static double calculate(double a,double b,double c,double d){
return (a*b+c*d);
}
public static double roundNumber(double num, int dec){
return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
double x1,y1,x2,y2;
double temp=0,max=0;
int cases=sc.nextInt();
double[] a1=new double[cases],a2=new double[cases];
for(int i=0;i<cases;i++){
a1[i]=sc.nextDouble();a1[i]=roundNumber(a1[i],3);
a2[i]=sc.nextDouble();a2[i]=roundNumber(a2[i],3);
}
for(int i=0;i<cases;i++){
x1=a1[i];y1=a2[i];
for(int j=0;j<cases;j++){
x2=a1[j];y2=a2[j];
temp=calculate(x1,x2,y1,y2);
if(temp>max)max=temp;
}
max=roundNumber(max,3);
System.out.format("%.3f%n",max);
temp=0;max=0;
}
}
}
can anyone help me?