Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This project is intended for you to use programming concepts such as decision st

ID: 3620224 • Letter: T

Question

This project is intended for you to use programming concepts such as decision statements, loop statements and especially the String and Character classes and apply them in a simple Java program.

Write a Java program that may be part of a game, scoring points for words. It should:
1. Ask the user to type in a word, using a JOptionPane.showInputDialog().
2. Look at each letter in the word and add up the points for each letter. The points for letters are:
a. Vowels ('a', 'e', 'i', 'o' and 'u') are valued at zero.
b. The letters 'x' and 'q' are valued at 5.
c. All other letters are valued at 1.
d. Anything not a letter should be ignored.
e. Upper case and lower case letters count the same.
3. Using a JOptionPane.showMessageDialog(), display the word and the score.
4. Repeat this process until the user types the word "Stop".

Thank you.

Explanation / Answer

import javax.swing.*; class WordScore { public static void main(String[] args) { String input; final String VOWELS = "aeiouAEIOU"; final String POINTS5 = "xqXQ"; while(!(input=JOptionPane.showInputDialog("Enter a word:")).equals("Stop")) { // calculate score int score = 0; for(char c : input.toCharArray()) { if(VOWELS.indexOf(c) >= 0) { score += 0; } else if(POINTS5.indexOf(c) >= 0) { score += 5; } else if(Character.isLetter(c)) { score ++; } } JOptionPane.showMessageDialog(null, input+" : "+score, "Score", JOptionPane.INFORMATION_MESSAGE); } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote