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