Need help, script closing after first user answer

Jun 20, 2012 at 7:28pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>

using namespace std;

int main (){


    string Answer;

    cout << "Text" << endl;
    cout << "Text" << endl;
    cout << "text" << endl;
    cout << "text" << endl;
    cin >> Answer;




    if(Answer == "B"){
            cout << "text" << endl;
            cout << "text" << endl;
            cout << "text" << endl;



    }
    else if (Answer == "BC"){
        cout << "text" << endl;



    }
    else if (Answer == "AB"){
        cout << "text" << endl;





    }
    else if(Answer == "A"){
           cout << "text" << endl;






    }
    else{

    }

}
 






Basicly, i want the script to be able to let me type in another alternative. But after the "cin" command the script will just print the text and just stop running.
Last edited on Jun 20, 2012 at 7:40pm
Jun 20, 2012 at 7:36pm
Man i can help you but i didnt understand what you want to change.
Explain me again because i am not good in english,or add me in skype:magas1291
Jun 20, 2012 at 7:40pm
Basicly, i want the script to be able to let me type in another alternative. But after the "cin" command the script will just print the text and just stop running.
Jun 20, 2012 at 7:42pm
I mean, I want the script allow me to type in more than just 1 answer.
I'm not really "good" at explaining or english, but i attempt to do my best.
Last edited on Jun 20, 2012 at 7:43pm
Jun 20, 2012 at 7:43pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <cstdlib>



using namespace std;

int main (){


    string Answer;

    cout << "Text" << endl;
    cout << "Text" << endl;
    cout << "text" << endl;
    cout << "text" << endl;
    cin >> Answer;




    if(Answer == "B"){
            cout << "text" << endl;
            cout << "text" << endl;
            cout << "text" << endl;



    }
    else if (Answer == "BC"){
        cout << "text" << endl;



    }
    else if (Answer == "AB"){
        cout << "text" << endl;





    }
    else if(Answer == "A"){
           cout << "text" << endl;






    }
    system("pause");

}


Something like this?
also i got away the <else> in the end
because you havent put anything and it is useless
Jun 20, 2012 at 7:44pm
You should use a loop if you want to run the code again.
Jun 20, 2012 at 7:45pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <cstdlib>



using namespace std;

int main (){


    string Answer;

    cout << "Text" << endl;
    cout << "Text" << endl;
    cout << "text" << endl;
    cout << "text" << endl;
    cin >> Answer;




    if(Answer == "B"){
            cout << "text" << endl;
            cout << "text" << endl;
            cout << "text" << endl;



    }
    else if (Answer == "BC"){
        cout << "text" << endl;



    }
    else if (Answer == "AB"){
        cout << "text" << endl;





    }
    else if(Answer == "A"){
           cout << "text" << endl;






    }
    else
    {
        cout<<"You havent put a valid character";
    }
    system("pause");

}

i made the <else> in the end.So i helped you?
Last edited on Jun 20, 2012 at 7:45pm
Jun 20, 2012 at 7:46pm
Zhuge, i admit your right.
Jun 20, 2012 at 7:46pm
Man i cant understand you.
You want ,the program to ask you many times?
Jun 20, 2012 at 7:47pm
thanks for helping me both of you, marking as solved
Jun 20, 2012 at 7:50pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>




using namespace std;

int main (){

char playagain='y';

    while(playagain=='y')
    {
        string Answer;

    cout << "Text" << endl;
    cout << "Text" << endl;
    cout << "text" << endl;
    cout << "text" << endl;
    cin >> Answer;




    if(Answer == "B"){
            cout << "text" << endl;
            cout << "text" << endl;
            cout << "text" << endl;



    }
    else if (Answer == "BC"){
        cout << "text" << endl;



    }
    else if (Answer == "AB"){
        cout << "text" << endl;





    }
    else if(Answer == "A"){
           cout << "text" << endl;






    }
    else
    {
        cout<<"You havent put a valid character";
    }

cout<<"\n\nwanna play again(y/n)";
cin>>playagain;
cout<<endl;
if(playagain=='y')
{
    cout<<"\nchoice to play again\n\n";
}
else if(playagain=='n')
{
    cout<<"\nchoice not to play again\n";
}
else
{
    cout<<"\nput an invalid character so the program will close\n";
}




}


}

Now i helped you?
Jun 20, 2012 at 7:52pm
Yeah, thanks mate :)
Last edited on Jun 20, 2012 at 7:52pm
Jun 20, 2012 at 7:57pm
No problem.If you want add me in skype to hlp you whenever you want.(i gave it to you up)
Topic archived. No new replies allowed.