I need help writing the following Java program. In most word games, each letter
ID: 3671981 • Letter: I
Question
I need help writing the following Java program.
In most word games, each letter in a word is scored according to its point value, which is inversely proportional to its frequency in English words. In Scrabble, the points and letter distribution are allocated as shown in the table. Write a Java program that reads in a word (not a sentence) and prints out the score in Scrabble, not counting any other bonuses that occur in the game. Make sure the program handles blank tiles. Represent a blank tile with a #. For example, the Scrabble word "FARM"is worth 9 points: 4 for the F, 1 each for the A and the R, and 3 for the M. However, the word SYZYGY-should be worth: 1 + 4 +10+ 4 + 2 + 0 = 21 points since Y is only found twice a blank tile must be used. Check for the proper number of tiles- assume a maximum of seven letters on a rack as well as ignore any characters other than uppercase letters in computing the score. Output should look similar to below. Enter a word: SYZYGY English-language editions of Scrabble contain 100 letter tiles, in the following distribution:Explanation / Answer
import java.util.*;
class word_score
{
public static void main(String args[])
{
String s;
int a[]=new int[10],i,sum=0;
char c;
Scanner scan = new Scanner
(System.in);
s=scan.nextLine();
for(i=0;i<s.length();i++)
{
c=s.charAt(i);
if(c== 'E' || c=='A' ||c==
'I' ||c== 'O' ||c== 'N' ||c== 'R' ||c== 'T' ||c== 'L' ||c== 'S'
||c== 'U')
{
a
[i]=1;
}
if(c== 'D' || c=='G')
{
a
[i]=2;
}
if(c== 'B' || c=='C' ||c==
'M' ||c== 'P')
{
a
[i]=3;
}
if(c== 'F' || c=='H' ||c==
'V' ||c== 'W' ||c== 'Y')
{
a
[i]=4;
}
if(c== 'K')
{
a
[i]=5;
}
if(c== 'J' || c=='X' )
{
a
[i]=8;
}
if(c== 'Q' || c=='Z' )
{
a
[i]=10;
}
}
for(i=0;i<s.length();i++)
{
System.out.print(a[i]+"+");
sum=sum+a[i];
}
System.out.print(" ="+sum);
}
}