200
69
30
Sample output:
The corresponding output is given here. For example:
200invalid!
1
1
Code length limit 16 KB
Time limit 6000 ms
Memory limit 64 MB
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = 0, b = 0;
for (int i = 0; i < n; i++) {
score score = new score();
try {
score.setScore(sc.nextInt());
int val = score.getScore();
if (val >= 60) a++;
else b++;
} catch (IllegalScoreException e) {
i--;
System.out.println(score.toString());
}
}
System.out.println(a);
System.out.println(b);
}
}
class score {
private int score;
public score() {
}
public int getScore() {
return score;
}
public void setScore(int score) throws IllegalScoreException {
this.score = score;
if (score < 0 || score > 100) {
throw new IllegalScoreException();
}
}
@Override
public String toString() {
return score + "invalid!";
}
}
class IllegalScoreException extends Exception {
}