Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA * * My code does not give me exactly the sample input and output mentioned in the question.. kindly make the necessary changes to

JAVA*
*My code does not give me exactly the sample input and output mentioned in the question.. kindly make the necessary changes to let it match the sample input and output both*
Problem: ACSL Scrabble is a lettered tile game played on a grid game board. The board for this program will be 4 x 10. The grid squares are numbered as below:
the grid is from the numbers from 1 to 40
The squares that are every other multiple of 3(3,9,15...) are Double Letter score squares.
The squares that are multiples of 5 and not used above are Triple Letter score squares.
The squares that are multiples of 7 and not used above are Double Word score squares.
The squares that are multiples of 8 and not used above are Triple Word score squares.
Letter values will come from the following chart:
A, E -1 point D, R -2 points B, M -3 points V, Y -4 points J, X -8 points
INPUT: There will be 6 lines of input. The first line will give the letters of the word. The word will always have 4 letters. The remaining 5 lines will be starting locations for the word. Words will only be placed horizontally across the grid.
OUTPUT: For each starting location, print the total points scored by the word. No word will have more than one word score multiplier.
SAMPLE INPUT
1. J, A, V, A
2.1
3.2
4.4
5.12
6.21
SAMPLE OUTPUT
1.18
2.17
3.32
4.30
5.66
Code:
public class Main {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int[] Array_scrbl ={1,1,3,2,3,4,4,2,1,8,4,3,3,1,1,3,4,1,1,1,1,4,3,8,4};
System.out.print(\"1.\");
String w = scnr.nextLine().toUpperCase().replaceAll(\",\\\\s*\",\"\");
char[] L = w.toCharArray();
int[] startingLocation = new int[5];
//System.out.println(\"Enter the starting location\");
for(int i =0;i<5;i++){
System.out.print((i +2)+\".\");
startingLocation[i]= scnr.nextInt();
}
for(int i=0;i<5;i++){
int current = startingLocation[i];
int total_points =0;
for(int j =0;j<4;j++){
char charLetter = L[j];
int value = Array_scrbl[charLetter -\'A\'];
if (current %3==0){
total_points+=2*value;
}
else if(current%5==0){
total_points+=3*value;
}
else{
total_points=total_points+value;
}
current++;
if(current>40){
current =1;
}
}
int multiplier =1;
if((current-1)%7==0){
multiplier=2;
}
else if((current-1)%8==0){
multiplier =3;
}
total_points = total_points*multiplier;
System.out.println((i+1)+\".\"+total_points);
}
}
}

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions