Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

}

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

Students also viewed these Databases questions

Question

=+j Enabling a productive global workforce.

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago