+ 3

How to go to next test case

I’m on module 6, doing the project on 2 pi. I got test case 1 correct how do I go to test case 2?

21st Apr 2021, 11:58 AM
Mohammad Totah
Mohammad Totah - avatar
15 Antworten
+ 3
Your code has to work for all test cases. Therefore it is given some input that you have to use to generate the matching output. Your code stays the same, only the input changes
21st Apr 2021, 12:44 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 3
You aren’t reading “radius” from your scanner input. SoloLearn passes input to the code for each test case. You must read in the input. Try this: Instead of: int radius = 4; Try: int radius = scanner.nextInt(); // Read user input That way each test case will run with different radius values to test your code.
21st Apr 2021, 6:10 PM
Jerry Hobby
Jerry Hobby - avatar
+ 2
Mohammad Totah import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 2 * 3.14; //your code goes here int radius = scanner.nextInt(); System.out.println(radius); } }
22nd Apr 2021, 5:15 AM
Atul [Inactive]
+ 2
Thank you kindly that makes sense now. I assume after that I click run and then implement the input number?
22nd Apr 2021, 5:17 AM
Mohammad Totah
Mohammad Totah - avatar
+ 1
Post your code, question. And specify the language too
21st Apr 2021, 1:37 PM
Atul [Inactive]
+ 1
If your code successfully passes the first test, the second test will execute automatically. The computer will use different inputs and your code should work. If your code meets the requirements, it will succesfully calculate all test cases. It only stops when a test case fails. Show us your code and maybe we can figure out why it’s failing.
21st Apr 2021, 5:48 PM
Jerry Hobby
Jerry Hobby - avatar
+ 1
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; //your code goes here int radius = 4; double perimeter = (2 * pi * radius); System.out.println(perimeter); } }
21st Apr 2021, 5:54 PM
Mohammad Totah
Mohammad Totah - avatar
+ 1
Thank you kindly but how would i implement 4 into that equation?
22nd Apr 2021, 4:16 AM
Mohammad Totah
Mohammad Totah - avatar
0
By typing 4 when it is asked to give input
22nd Apr 2021, 4:34 AM
Atul [Inactive]
0
So would it be int radius = scanner.nextInt(4)?
22nd Apr 2021, 4:41 AM
Mohammad Totah
Mohammad Totah - avatar
0
No it can't be in code coach just use scanner.nextInt(). That's all
22nd Apr 2021, 4:57 AM
Atul [Inactive]
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 2 * 3.14; //your code goes here int radius = Scanner.nextInt(); System.out.println(4); } }
22nd Apr 2021, 5:07 AM
Mohammad Totah
Mohammad Totah - avatar
0
Im confused my apologies all for being a bother
22nd Apr 2021, 5:08 AM
Mohammad Totah
Mohammad Totah - avatar
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 2 * 3.14; //your code goes here int radius = scanner.nextInt(); System.out.println(radius); } } If input is 4 how do i get output of 25.12?
22nd Apr 2021, 5:38 AM
Mohammad Totah
Mohammad Totah - avatar
0
Id like to thank you all i have finally solved it ☺️
22nd Apr 2021, 6:21 AM
Mohammad Totah
Mohammad Totah - avatar