Below is the code for my if-statement, which is supposed to print out the String "Weird" or "Not Weird" depending on the value of n.
public class Solution {
public static String weirdOrNotWeird(){
int n;
String ans = "";
// if n is odd or n is even & 5 < n < 21 print Weird
if((n % 2 == 1) || ((n % 2 == 0) && (n > 5 && n < 21))){
System.out.println("Weird");
ans = "Weird";
// otherwise print Not Weird
} else {
System.out.println("Not Weird");
ans = "Not Weird";
}
return ans;
}
}
When I compile, I get a runtime error that says "no response on stdout", and so doesn't give me an output.
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
scanner.close();
}
This is the rest of the code from the problem, but I don't have any errors in this part.
Aucun commentaire:
Enregistrer un commentaire