Skip to content

Instantly share code, notes, and snippets.

@ecornell
Created October 15, 2015 01:38
Show Gist options
  • Save ecornell/3ee260e94c5603bc1bfd to your computer and use it in GitHub Desktop.
Save ecornell/3ee260e94c5603bc1bfd to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
namespace ForumPrograms {
class Program {
static void Main(string[] args) {
Console.Write("Calculate the Scrabble point value of a word\n");
String input;
do {
Console.Write("\nEnter word: ");
input = Console.ReadLine();
int pointValue = 0;
foreach (var letter in input.ToUpper()) {
if ("EAIONRTLSU".Contains(letter)) {
pointValue += 1;
} else if ("DG".Contains(letter)) {
pointValue += 2;
} else if ("BCMP".Contains(letter)) {
pointValue += 3;
} else if ("FHVWY".Contains(letter)) {
pointValue += 4;
} else if ("K".Contains(letter)) {
pointValue += 5;
} else if ("JX".Contains(letter)) {
pointValue += 8;
} else if ("QZ".Contains(letter)) {
pointValue += 10;
} else {
// invalid letter
}
}
Console.Write("\n" + input + " has the point value of " + pointValue + "\n");
Console.Write("\nCalculate another word (y/n) : ");
input = Console.ReadLine();
} while (input.Equals("y"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment