+ 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?
15 Respostas
+ 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
+ 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.
+ 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);
}
}
+ 2
Thank you kindly that makes sense now. I assume after that I click run and then implement the input number?
+ 1
Post your code, question. And specify the language too
+ 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.
+ 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);
}
}
+ 1
Thank you kindly but how would i implement 4 into that equation?
0
By typing 4 when it is asked to give input
0
So would it be int radius = scanner.nextInt(4)?
0
No it can't be in code coach just use scanner.nextInt(). That's all
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);
}
}
0
Im confused my apologies all for being a bother
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?
0
Id like to thank you all i have finally solved it âșïž