id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

byngcompsci@gmail.com > computeScore
prev  |  next  |  chance

In SCRABBLE, different letters are assigned different numbers of points. Write a method computeScore(String word) that returns the score for a word without using either if or switch statements. Hint: find the position of a given letter in the alphabet string by calling indexOf; get the score for that letter from the array of point values, and add to the total.


computeScore("marine") → 8
computeScore("medic") → 10
computeScore("firebat") → 12

...Save, Compile, Run (ctrl-enter)

public int computeScore(String word) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy