Problem Code: ELEVSTRS .I have written a code but its showing wrong answer ..can anyone help me fix this...although this is a very easy question..

//my code
import java.util.Scanner;
import java.lang.* ;
class ELEVSTRS{public static void main(String[] arg){
Scanner in =new Scanner (System.in);
int T=in.nextInt();
String ar[]=new String[T];
for (int i=0;i<T;i++)
{double N=in.nextDouble();
double V1=in.nextDouble();
double V2=in.nextDouble();
if(((Math.sqrt(2)N)/V1 )> (2N/V2) ){ar[i]=“ELEVATOR”;}
if(((Math.sqrt(2)N)/V1)< (2N/V2) ){ar[i]=“STAIRS”;}
if(((Math.sqrt(2)N)/V1)== (2N/V2) ){if(((Math.sqrt(2)N)%V1)< (2N%V2) )
ar[i]=“STAIRS”;
else ar[i]=“ELEVATOR”;}
}for
(int j=0;j<T;j++)
{System.out.println(ar[j]);}}}

hi,

You printed string in uppercase while in question it is in camel case.

//my code import java.util.Scanner; import java.lang. ; class ELEVSTRS{public static void main(String[] arg){ Scanner in =new Scanner (System.in); int T=in.nextInt(); String ar[]=new String[T]; for (int i=0;i<t;i++) {double="" n=“in.nextDouble();” double="" v1=“in.nextDouble();” double="" v2=“in.nextDouble();<br”/>if(((Math.sqrt(2)*N)/V1 )> (2N/V2) ){ar[i]=“Elevator”;} if(((Math.sqrt(2)N)/V1)< (2N/V2) ){ar[i]=“Stairs”;} if(((Math.sqrt(2)N)/V1)== (2N/V2) ){if(((Math.sqrt(2)N)%V1)< (2N%V2) ) ar[i]=“Stairs”; else ar[i]=“Elevator”;} }for (int j=0;j<T;j++) {System.out.println(ar[j]);}}}

Even you have no need to store it in array at every test case you have to just print the answer.

The code is almost correct!

Replace

  1. “ELEVATOR” with “Elevator”
  2. “STAIRS” with “Stairs”

Here is the


[1].


  [1]: https://ideone.com/qoQ7dE

thank you.

thank you.

//