Turbo c++ code for jumble word game please give it fast
Thank you
Answers
Answered by
1
Just try this...
Base the point value on the word length (hint: use string funtions).
Deduct a point every time the player asks for a hint.
When the player guesses the word, tell him how many points he earned.
Add a loop so the player can guess another word.
Keep a running total of the overall points.
what I got so far is:
01// Word Jumble
02// The classic word jumble game where the player can ask for a hint
03
04#include <iostream>
05#include <string>
06#include <cstdlib>
07#include <ctime>
08
09using namespace std;
10
11int main()
12{
13enum fields {WORD, HINT, NUM_FIELDS};
14const int NUM_WORDS = 5;
15const string WORDS[NUM_WORDS][NUM_FIELDS] =
16{
17{"wall", "Do you feel you're banging your head against something?"},
18{"glasses", "These might help you see the answer."},
19{"labored", "Going slowly, is it?"},
20{"persistent", "Keep at it."},
21{"jumble", "It's what the game is all about."}
22};
23
24srand(time(0));
25int choice = (rand() % NUM_WORDS);
26string theWord = WORDS[choice][WORD]; // word to guess
27string theHint = WORDS[choice][HINT]; // hint for word
28
29string jumble = theWord; // jumbled version of word
30int length = jumble.size();
31for (int i=0; i<length; ++i)
32{
33int index1 = (rand() % length);
34int index2 = (rand() % length);
35char temp = jumble[index1];
36jumble[index1] = jumble[index2];
37jumble[index2] = temp;
38}
39
40cout << "\t\t\tWelcome to Word Jumble!\n\n";
41cout << "Unscramble the letters to make a word.\n";
42cout << "Enter 'hint' for a hint.\n";
43cout << "Enter 'quit' to quit the game.\n\n";
44cout << "The jumble is: " << jumble;
45
46string guess;
47cout << "\n\nYour guess: ";
48cin >> guess;
49
50while ((guess != theWord) && (guess != "quit"))
51{
52if (guess == "hint")
53cout << theHint;
54else
55cout << "Sorry, that's not it.";
56
57cout <<"\n\nYour guess: ";
58cin >> guess;
59}
Hope it helps you buddy..
Base the point value on the word length (hint: use string funtions).
Deduct a point every time the player asks for a hint.
When the player guesses the word, tell him how many points he earned.
Add a loop so the player can guess another word.
Keep a running total of the overall points.
what I got so far is:
01// Word Jumble
02// The classic word jumble game where the player can ask for a hint
03
04#include <iostream>
05#include <string>
06#include <cstdlib>
07#include <ctime>
08
09using namespace std;
10
11int main()
12{
13enum fields {WORD, HINT, NUM_FIELDS};
14const int NUM_WORDS = 5;
15const string WORDS[NUM_WORDS][NUM_FIELDS] =
16{
17{"wall", "Do you feel you're banging your head against something?"},
18{"glasses", "These might help you see the answer."},
19{"labored", "Going slowly, is it?"},
20{"persistent", "Keep at it."},
21{"jumble", "It's what the game is all about."}
22};
23
24srand(time(0));
25int choice = (rand() % NUM_WORDS);
26string theWord = WORDS[choice][WORD]; // word to guess
27string theHint = WORDS[choice][HINT]; // hint for word
28
29string jumble = theWord; // jumbled version of word
30int length = jumble.size();
31for (int i=0; i<length; ++i)
32{
33int index1 = (rand() % length);
34int index2 = (rand() % length);
35char temp = jumble[index1];
36jumble[index1] = jumble[index2];
37jumble[index2] = temp;
38}
39
40cout << "\t\t\tWelcome to Word Jumble!\n\n";
41cout << "Unscramble the letters to make a word.\n";
42cout << "Enter 'hint' for a hint.\n";
43cout << "Enter 'quit' to quit the game.\n\n";
44cout << "The jumble is: " << jumble;
45
46string guess;
47cout << "\n\nYour guess: ";
48cin >> guess;
49
50while ((guess != theWord) && (guess != "quit"))
51{
52if (guess == "hint")
53cout << theHint;
54else
55cout << "Sorry, that's not it.";
56
57cout <<"\n\nYour guess: ";
58cin >> guess;
59}
Hope it helps you buddy..
adityamangal16oykr72:
Thank you but can you send a picture of running of this code
Similar questions