Question: public class ScrabbleScore { public static void main(String[] args) { //Declaring variables String str; int score; //Scanner object is used to get the inputs entered

public class ScrabbleScore { public static void main(String[] args) {

//Declaring variables String str; int score; //Scanner object is used to get the inputs entered by the user Scanner sc=new Scanner(System.in); //This loop continues to execute until the user enters a valid string while(true) { //getting the string entered by the user System.out.println("Enter the Strng :"); str=sc.nextLine(); /* calling the method by passing * the user entered string as argument */ score=calculateScore(str); //If the returned value of the method is -1 then display error message if(score==-1) { System.out.println("** Invalid String **"); continue; } else { //Displaying the Score of the string System.out.println("Score :"+score); break; } } }

/* This method will calculate the score for the String * @ params word of type String * @return score of type integer */ public static int calculateScore(String word) { int score=0; for(int i=0;i

}

public class ScrabbleScore { public static void main(String[] args) { //Declaring variablesString str; int score; //Scanner object is used to get the inputs

Source Histor package MyUnitTests; 9 import org junit .Test SA L import static org. junit. Assert 12 14 Cauthor ara derma 16 public class Scrabble Score Test 17 Scrabble score Test 18 public 20 21 ETest public void templateTest 23 setup test values 24 set expected result 26 27 get actual result 28 29 compare expected and actual results 30 31 32 33 34 35 37 Source Histor package MyUnitTests; 9 import org junit .Test SA L import static org. junit. Assert 12 14 Cauthor ara derma 16 public class Scrabble Score Test 17 Scrabble score Test 18 public 20 21 ETest public void templateTest 23 setup test values 24 set expected result 26 27 get actual result 28 29 compare expected and actual results 30 31 32 33 34 35 37

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!