Question: How to Add the ability to save data to a disk in one or more files. The menu or menus should give the user the

How to Add the ability to save data to a disk in one or more files. The menu or menus should give the user the option to save or retrieve data in this program?

#include

#include

using namespace std;

// These are the function prototype/declaration which we need to tell the compiler before defining the functions.

int wordgame();

int talkabout(string);

int maths(string);

int mathgame();

int main()

{

string userName;

cout<<"Hi Whats your name? "<

cin>>userName;

cout << userName << "Nice to meet you, My name is Raphie"<

wordgame();

talkabout(userName);

maths(userName);

}

int wordgame()

{

const int a = 3;

string word[a] = { "apple","ball","cat" };

string nword[a] = { "lppea","lalb","cta" };

string j;

int point=0;

int ctr = 0;

for (int i = 0; i

{

cout << nword[i] << endl;

cout<<"Please enter the word you think is correct"<

fflush(stdin);

cin >> j;

ctr++;

if (j == word[i])

{

cout << "==========Congratulation=========" << endl;

cout << "==========You Have Score:" << endl;

cout << " " << "1" << " " << "Point" << endl;

point++;

// Determining if the correct responce would give the wanted result..

}

else

{

cout << "Wrong" << endl;

}

cout << "Your Score Is:" << point << endl;

}

}

int talkabout(string userName)

{

int sAnimals1, sshapes2, sMachines3;

cout << userName << "Would you like to talk about" << endl;

cout << " 1 : " << "Animals" << endl;

cout << " 2 : " << "shapes" << endl;

cout << " 3 : " << "Machines" << endl;

cout << " 4 : Exit Game " << endl;

int choice;

cout << "Your choice: " ;

cin >> choice;

switch (choice)

{

case 1:

cout << "Animals Ok!..." << endl;

break;

case 2:

cout << "Shapes Ok!..." << endl;

break;

case 3:

cout << "Machines Ok!..." << endl;

break;

case 4:

cout << "Exiting Game..." << endl;

break;

}

}

int maths(string userName)

{

int mathGame, exitGame,choice;

cout << userName << "would you like to play a Math game ?" << endl;

cout << "1 for Yes or 2 for No" << endl;

cout << " 1 : " << "mathGame" << endl;

cout << " 2 : " << "exitGame" << endl;

//int choice = 0;

cout << "Your choice: ";

cin >> choice;

switch (choice)

{

case 1:

cout << "Math Ok!..." << endl;

mathgame();

break;

case 2:

cout << "Exit Ok, good by..." << endl;

break;

}

}

int mathgame()

{

int whatsNeeded;

int missingVariblies[3] = {4,5,6};

//missingLetter[0]= 4;

//missingLetter[1]= 5;

//missingLetter[2]= 6;

cout << "What is equal to 5" << endl;

cout << "If you already have Two apples how many more do you need" << endl;

cin >> whatsNeeded;

if (3 == whatsNeeded)

{

cout << "the total is" << missingVariblies[1] << "your correct!!!!!" << endl;

}

else

{

cout << "Please try again";

}

}

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!