Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int balls = Integer.parseInt((scanner.nextLine())),
- red = 0, orange = 0, yellow = 0, white = 0,
- black = 0, other = 0, totalPoints = 0;
- String color;
- for (int i = 0; i < balls; i++) {
- color = scanner.nextLine();
- switch (color) {
- case "red" -> {
- totalPoints += 5;
- red++;
- }
- case "orange" -> {
- totalPoints += 10;
- orange++;
- }
- case "yellow" -> {
- totalPoints += 15;
- yellow++;
- }
- case "white" -> {
- totalPoints += 20;
- white++;
- }
- case "black" -> {
- totalPoints /= 2;
- black++;
- }
- default -> other++;
- }
- }
- System.out.printf("Total points: %d\n", totalPoints);
- System.out.printf("Red balls: %d\n", red);
- System.out.printf("Orange balls: %d\n", orange);
- System.out.printf("Yellow balls: %d\n", yellow);
- System.out.printf("White balls: %d\n", white);
- System.out.printf("Other colors picked: %d\n", other);
- System.out.printf("Divides from black balls: %d\n", black);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement