Need to modify my first program.

Hi Guys,

I hope some one can help me how to modifey this program, and make it better , i just need some one to answer my question by the codes.
i am trying to make simple chat on the council . and need answers on my below questions .

the program like below
// Lesson cout. cin

#include <iostream>
#include <string>
#include <stdlib.h>
#include <cctype>
using namespace std;

int main ()
{
string mystr;
cout << "WHAT IS YOUR NAME? " << endl; // print question on screen.
getline (cin, mystr); //user input.
cout << "HELLO " << mystr << endl; //welcome output.


cout <<"IS SAM YOUR SON? PLEASE TYPE y/n " << endl;
char answer;
cin >> answer;

if (answer=='y') //if the user type y.
{cout << "YOU ARE LUCKY.. HE IS SMART BOY. " << endl;


cout << " CAN I MEET HIM TODAY ? " << endl;
char response;
cin >> response;

return 1;
}
if (answer=='n'); //if the user type n.
{

cout << " DO NOT LIE .. YOU FORGOT THAT I AM COMPUTER !. "<<endl;
}

system("pause");
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
and my questions are :
1- when the user type the answer in lowercase i want it to show in uppercase .
2 if the user reply on first question ( mystr ) by (my name is Tom) how not to show the ( my name is ) and keep his name in the welcome screen.(next line).
3- how to change (y/n) to (yes / no ) .
4 if the user did not type yes/no how to print msg ( unexpected result ).

please any one can help .
Last edited on
1.
if (answer == 'n' || answer == 'N') or if (toupper(answer) == 'N')

3.
Write string response or char response[256] instead of char response

4. Replace if(answer=='n') with else if (answer == 'n'), then at the end of that if, put
else { cout << "ERROR MESSAGE"; }
Last edited on
Topic archived. No new replies allowed.