I entered the below code in the editor for submitting my answer and I got a compile error saying that my file name was not matching my class!?! I never specified a class name.
I tried sending a file attachment and same failure error. Here is my code:
//Bear and Candies 123 = Beginner problem on CodeChef
import java.util.Scanner;
public class Bears {
public static void main(String[] args) {
int testCaseNumber = 0;
String testCase = "";
Scanner inputReader = new Scanner(System.in);
// Get the number of test cases from the user
while (testCaseNumber < 1 || testCaseNumber > 1000) {
System.out.println("Enter the number of test cases 1 <= number <= 1000:");
testCaseNumber = inputReader.nextInt();
}
inputReader.nextLine();
for(int i = 1; i <= testCaseNumber; i++) {
int a = 0;
int b = 0;
int limak = 0;
int bob = 0;
while((a < 1 || b < 1) || (a > 1000 || b > 1000)) {
System.out.println("For test case #" + i + " Give two integers for the candy limit of Limak and Bob respectively 1 <= A&B <= 1000:");
testCase = inputReader.nextLine();
String[] numbers = testCase.split(" ");
a = Integer.parseInt(numbers[0]);
b = Integer.parseInt(numbers[1]);
}
for(int j = 1; j <= 1000; j += 2){
// check limak
limak += j;
if(limak > a){
System.out.println("Bob");
break;
}
//check bob
bob += j + 1;
if(bob > b){
System.out.println("Limak");
break;
}
}
}
}
}