+ 3
Locked test cases issue
I was answering a question on the test coach section. The title is "Hovercraft ", i saw told that i failed one test case out five, How will i know what to change in d code when the test case is locked.
12 Respuestas
+ 1
//Try this...
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int sales = input.nextInt();
if( sales > 7){
System.out.println(" Profit ");
}else if( sales == 7){
System.out.println(" Broke Even ");
}else if ( sales <= 5){
System.out.println(" Loss ");
}
}
}
+ 1
Muiz Kolapo HARUNA
Sales = 6 case is missing..
Simply put
if(sales > 7) System.out.println ("Profit") ;
else if (sales < 7) System.out.println("Loss") ;
else System.out.println("Broke Even") ;
Note : don't include extra spaces in output.
+ 1
import java.util.Scanner;
public class Program
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int n= input.nextInt();
if(n==7)System.out.println("Broke Even");
else if(n<7)System.out.println("Loss");
else System.out.println("Profit");
}
}
Check this Muiz Kolapo HARUNA ,this might help you...
+ 1
you are welcome
0
you dont know, but maybe we can help you if you post your code...
In most cases the test cases are just so big that e.g. integer is to small....
0
Show ur atte
0
Muiz Kolapo HARUNA show ur attempt
0
Ok i will
0
Here
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int sales = input.nextInt();
if( sales == 10){
System.out.println(" Profit ");
}else if( sales < 10 && sales > 5){
System.out.println(" Broke Even ");
}else if ( sales <= 5){
System.out.println(" Loss ");
}
}
}
Its telling me i failed a test case and d case is hidden
0
If you make 9 sales, then you make a profit arent you??
But your programm says it would be broke even...
0
Thanks so much everybody
0
I had refactored it and i passed!!!