Statistics

Problem Statement for "Scoreboard"

Problem Statement

You have been hired by a gaming company that makes pinball machines. They are currently making a simple and small pinball machine designed for kids' home use. As the company's newest Pinball Engineer, your job is to make sure that the right score is displayed on the machine. Players can get points by hitting bumpers, moving over rollers, or executing a tricky sequence which gets them the jackpot or double jackpot.

Write a function which returns the correct number of points the player has earned so far. The input string, events, consists of characters indicating what has happened:

  • 'B' indicates the ball hit a large bumper. This is worth 1,000 points.
  • 'b' indicates the ball hit a small bumper. This is worth 250 points.
  • 'R' indicates the ball went over a roller. This is worth a measly 50 points.
  • 'J' means the player got the jackpot and earns 10,000 points.
  • 'D' means the player got the double jackpot and gets 20,000 points.

Definition

Class:
Scoreboard
Method:
getScore
Parameters:
String
Returns:
int
Method signature:
int getScore(String events)
(be sure your method is public)

Constraints

  • Events will have a length from 0 to 50 characters, inclusive.
  • Events will have no characters other than 'B', 'b', 'R', 'J', and 'D'.

Examples

  1. "BBB"

    Returns: 3000

    Three large bumpers, at 1000 points each, is worth 3000 points.

  2. "BbRJD"

    Returns: 31300

    One of each scoring: B = 1000, b = 250, R = 50, J = 10000, D = 20000 => Total = 31300

  3. ""

    Returns: 0

    Much sadness, as there was no score at all.

  4. "JJRRBbD"

    Returns: 41350

  5. "bbRRBD"

    Returns: 21600

  6. "BbRJD"

    Returns: 31300

  7. "DDJJJbJRDDDBRbBBJbBRJJbDBRbDRBJBbbRBbRDDBDDJRBBb"

    Returns: 323650

  8. "DR"

    Returns: 20050

  9. "RbbBJJRbDD"

    Returns: 61850

  10. "JbDJBDDJBbbRJJRbBbBJJJRRDBRRRBJDBDbRJbDRBbbDbDJ"

    Returns: 300950

  11. "BRRDJBbDJbDBRRBBRb"

    Returns: 86000

  12. "JbDRJbJJRRRBDRBbBR"

    Returns: 84050

  13. "BDJRDbRDDJBBbBRDDBDDJBRDRBbDJRBBJDBR"

    Returns: 281100

  14. "D"

    Returns: 20000

  15. "BbRJDRbb"

    Returns: 31850

  16. "RRBbb"

    Returns: 1600

  17. "BBbDDJBRbRJDRRDBDBDJRbbJbbDBRBbJDD"

    Returns: 239050

  18. "BBBBRBJBbBRJJbbJBbRBJJJRJJDBBBDBRJJDJDRJDB"

    Returns: 245300

  19. "RDRb"

    Returns: 20350

  20. "BRbRbDBRRRRJBJBBbbBBRbDBDDbRJBJBRBDJDRJJRbRB"

    Returns: 204350

  21. "JJbBBbRbBbDRBRRRRDbDbbDJbBJ"

    Returns: 127300

  22. "RRbDJRBbBRRDBJbDBBJDBBBRbbbRJRJ"

    Returns: 139900

  23. "RDDJDBJRRbRDbbDJDBJBbJRbRDJRbJRJJJbBJJDBRBRJJ"

    Returns: 308250

  24. "BBDbJRRJRRDRJbBbbbJJDBRDDDbbJJBbJRRJJBJBBDbBRRDRDJ"

    Returns: 311800

  25. "BDJDDDJDRJbbBDbJDbJbRBRJJBDbRbDDRBRbRJJJBDJDDDJRDD"

    Returns: 448400

  26. "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"

    Returns: 1000000

  27. "JJJJ"

    Returns: 40000


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: