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

I want to make a scrabble game in c++ . I want to use iostream , stdafx.h , and

ID: 3874997 • Letter: I

Question

I want to make a scrabble game in c++ . I want to use iostream , stdafx.h , and cstring libraries only . there are two players , they want to make words from these characters : ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ RSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST . these 2 players have to make words from these caracters till these caracters done . at the end all the words that the 2 players made by (cin) must be viewed on the screen by (cout ). every time a player enter a word, the characters of this word must be eliminated from the list of characters and make sure to calculate the score of each player according to : 1 point - A, E , I, L, N, O, R, S, T, U 2 point - D, G 3 point - B, C, M, P 4 point - F, H, V, W, Y 5 point - K 8 point - J, K 10 point - Q, Z

please i want it in a very simple way .

Explanation / Answer

//I have assumed that player make words alternatively and they make words only from the remaining set of characters at any point of time.

#include <iostream>
#include <cstring>

using namespace std;

int main() {
string input;
int arr[26],point[26]; //arr will store the characters count and point will store corresponding points
for(i=0; i<26; i++) {
arr[i]=0; //initializing with 0
}
point[0]=1; //since the points are all random so I need to store all of them separately
point[1]=3;
point[2]=3;
point[3]=2;
point[4]=1;
point[5]=4;
point[6]=2;
point[7]=4;
point[8]=1;
point[9]=8;
point[10]=8;
point[11]=1;
point[12]=3;
point[13]=1;
point[14]=1;
point[15]=3;
point[16]=10;
point[17]=1;
point[18]=1;
point[19]=1;
point[20]=1;
point[21]=4;
point[22]=4;
point[23]=5;
point[24]=4;
point[25]=10;
int flag=0,count,i,j,p1=0,p2=0;
input = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST"; //gven set of characters
count = input.size(); //total number of characters
for(i=0; i<count; i++) {
arr[(int)input[i]-65]++; //storing the frequency of each character in the given set of characters
}
while(count>0) { //while loop till the characters still left to choose by the players
cin >> temp; //word made by the players
len = temp.size(); //number of characters in the word
if(flag==0) { //flag==0 means its player 1 turn
for(j=0; j<len; j++) {
arr[(int)temp[j]-65]--; //eleminating the characters from the given set
count--; //decresing the count every time
p1+=point[(int)temp[j]-65]; //points scored by player 1
}
flag=1; //over to player 2
}
else { //when player 2 turn
for(j=0; j<len; j++) {
arr[(int)temp[j]-65]--; //eleminating the characters from the given set
count--; //decresing the count every time
p2+=point[(int)temp[j]-65]; //points scored by player 2
}
flag=0; //over to player 1
}
cout << temp << endl; //printing the word made by players
}
cout << "Points of Player 1 = " << p1 << endl; //printing total points scored by player 1
cout << "Points of Player 2 = " << p2 << endl; //printing total points scored by player 2
return 0;
}

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