I'm confused...

So I wanna make a program the lets a new Student learn about the teacher. The console with pop up. They will type in "Questions" and a list of questions you can ask will pop up. I wanna know how I can assign text to certains ones... example if Someone asks the question "Favorite Color" I want it to respond with Blue or whatever the color is. But how would I do that? Sorry i'm new. Thanks!

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
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
    cout << "Hello, Welcome to all about Mr.Zeorth. This is a program made by Tyler, to inform you all about Mr.Zeorth" << endl;

    cout << "Type Questions to see a list of Questions you can ask." << endl;
   int Question;
   cin >> Question;
   cout << "Here's some questions you may ask..." << endl;
   cout << "Favorite color" << endl;
   cout << "Favorite nfl team" << endl;
   cout << "How many sons does he have?" << endl;


string Favorite_color;

if ("Favortie_color") {
cin << Favorite_color;
cout << "Blue";
}

ok a few problems here. first of all on line 12 you make an integer called Question. then on line 13 you ask the user to type something. This type of variable (integer) can only hold hole numbers (numbers that don't have a decimal point).

Next, i think you may be trying to fight the system here. why not try something a little more simplistic like this.

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
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
	int Question = 9;		//set up an intager variable. set it to a number not being used.
    cout << "Hello, Welcome to all about Mr.Zeorth. This is a program made by Tyler, to inform you all about Mr.Zeorth" << endl;   //Great the user

	while (Question != 0)				//Set up a loop so Students can ask more than 1 question. also set an exit so they can quit the program.
	{
		
	cout << "Here's some questions you may ask..." << endl;
   cout << "(1) Favorite color" << endl;
   cout << "(2) Favorite nfl team" << endl;							//Here you give students options of questions they can ask.
   cout << "(3) How many sons does he have?" << endl;
   cout << "(0) To quit" << endl;
  
    cout << "What question would you like to ask?" << endl;	//Ask for user input
   cin >> Question;					//Collect user input as an intager. This number will be used in a for loop to display an answer.
   
   
   

		if (Question ==1)		//set up the for loop (remember to use == NOT =)
		{
			cout << "Blue" << endl;
		}
		
		if (Question ==2)
		{
			cout << "Cowboys" << endl;
		}
		
		if (Question ==3)
		{
			cout << "0 but 2 daughters" << endl;
		}
	}

	return 0;
}
Thank you this helped alot!
Topic archived. No new replies allowed.