Write a command line application that takes a word and returns its Scrabble score. Here are the point values of each letter in Scrabble:
(A, E, I, O, U, L, N, R, S, T) 1,
(D, G) 2,
(B, C, M, P) 3,
(F, H, V, W,Y) 4,
(K) 5,
(J, X) 8,
(Q, Z) 10,
I JUST NEED A CODE THAT TAKES A LETTER FROM THE COMMAND LINE AND RETURNS A NUMBER AS DESCRIBED IN THE QUESTION.
zemiak
2
use
String[] values = {“AEIOULNRST”,“DG”,“BCMP”,“FHVWY”,“K”,"","",“JX”,"",“QZ”};
then
(values[i].indexOf(searchedChar) >=0)
or use
String values = “AEIOULNRST,DG,BCMP,FHVWY,K,JX,QZ,”;
then search char and count commas
if(values.charAt(i)==’,’)
result++;
import java.util.*;
public class Solution
{
public static void main(String str[])
{
String alphabet_arr[]=new String[]{“AEIOULNRST”,“DG”,“BCMP”,“FHVWY” ,“JX”,“QZ”};
int value_arr[]=new int[]{1,3,4,5,8,10};
Scanner s=new Scanner(System.in);
int score=0;
System.out.println(“enter word to chk score”);
String word=s.next();
for (int i=0;i<word.length();i++)
{
for(int j=0;j<alphabet_arr.length;j++)
{
if(alphabet_arr[j].indexOf(word.charAt(i))>=0)
score=score+value_arr[j];
}
}
System.out.println(“score is:”+score);
}
}