FINAL PROJECT Create a program that automatically generates words from letters.
ID: 656536 • Letter: F
Question
FINAL PROJECT
Create a program that automatically generates words from letters. Your program/project should be called [YourName]-Project.java (replace [YourName] with your actual name). The program should ask the user for 5 letters and then build valid English words using those letters (use each letter only once) and output them in a table format (showing per line: the word, its length, and its number of points) and organized (ordered) by one of these criteria:
Criteria Name Meaning and Order
1 Length Determine the length of the words (the number of letters in the word) and
show the words in the decreasing order of the word length
2 Points Determine the total number of points (the sum of the points/values for each
letter from the word
Explanation / Answer
class rajesh-project
{
public static void main(String args[])
{
char[] ch= new char[5];
int sum=0;
DataInputStream o = new DataInpiutStream(System.in);
System.out.println("Enter 5 characters");
for(i=0;i<5;i++)
{
ch=o.readLine();
switch (ch)
{
case 'A':
sum=sum+1;
break;
case 'B':
sum=sum+4;
break;
case 'C':
sum=sum+4;
break;
case 'D':
sum=sum+2;
break;
case 'E':
sum=sum+1;
break;
case 'F':
sum=sum+4;
break;
case 'G':
sum=sum+3;
break;
case 'H':
sum=sum+3;
break;
case 'I':
sum=sum+1;
break;
case 'J':
sum=sum+10;
break;
case 'K':
sum=sum+5;
break;
case 'L':
sum=sum+2;
break;
case 'M':
sum=sum+4;
break;
case 'N':
sum=sum+2;
break;
case 'O':
sum=sum+1;
break;
case 'P':
sum=sum+4;
break;
case 'Q':
sum=sum+10;
break;
case 'R':
sum=sum+1;
break;
case 'S':
sum=sum+1;
break;
case 'T':
sum=sum+1;
break;
case 'U':
sum=sum+2;
break;
case 'V':
sum=sum+5;
break;
case 'W':
sum=sum+4;
break;
case 'X':
sum=sum+8;
break;
case 'Y':
sum=sum+3;
break;
case 'A':
sum=sum+10;
break;
}
}
System.out.print("Total Characters ="+ch);
System.out.print("Total value is "+sum);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.