+ 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.

18th May 2020, 11:03 AM
Muiz Haruna
Muiz Haruna - avatar
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 "); } } }
18th May 2020, 11:39 AM
Alexander Thiem
Alexander Thiem - avatar
+ 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.
18th May 2020, 12:21 PM
Jayakrishna 🇮🇳
+ 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...
19th May 2020, 5:05 AM
Nikhil Maroju
Nikhil Maroju - avatar
+ 1
you are welcome
19th May 2020, 12:24 PM
Alexander Thiem
Alexander Thiem - avatar
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....
18th May 2020, 11:06 AM
Alexander Thiem
Alexander Thiem - avatar
0
Show ur atte
18th May 2020, 11:10 AM
Abhay
Abhay - avatar
0
Muiz Kolapo HARUNA show ur attempt
18th May 2020, 11:10 AM
Abhay
Abhay - avatar
0
Ok i will
18th May 2020, 11:13 AM
Muiz Haruna
Muiz Haruna - avatar
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
18th May 2020, 11:26 AM
Muiz Haruna
Muiz Haruna - avatar
0
If you make 9 sales, then you make a profit arent you?? But your programm says it would be broke even...
18th May 2020, 11:37 AM
Alexander Thiem
Alexander Thiem - avatar
0
Thanks so much everybody
19th May 2020, 10:08 AM
Muiz Haruna
Muiz Haruna - avatar
0
I had refactored it and i passed!!!
19th May 2020, 2:27 PM
Muiz Haruna
Muiz Haruna - avatar