Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int numberOfBalls = scanner.nextInt();
- String color = null;
- double sum = 0.0;
- for (int i = 0; i < numberOfBalls; i++) {
- color = scanner.next();
- switch(color) {
- case "red" : sum = sum + 5; break;
- case "orange" : sum += 10; break;
- case "yellow" : sum += 15; break;
- case "white" : sum += 20; break;
- case "black" : sum = Math.floor(sum/2.0);
- default : sum = sum;
- }
- }
- System.out.printf("Sum : %.0f", sum);
- }
- }
- /*
- 22
- black
- red
- yellow
- red
- white
- black
- blue
- red
- orange
- orange
- black
- green
- red
- purple
- white
- white
- orange
- orange
- red
- blue
- black
- white
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement