Multiple Choices

we are asked to create a program that will display a menu that will allow the user to choose a subject.
ex.
A.english
B.math
C.science

then, will ask for a letter of choice. display a corresponding trivia question based on the chosen subject, display also a list of answer to choose from, ask for the answer. evaluate the answer and display a remark like "wrong answer" or "correct!".

ex.
A.English
B.Math
C.Science

Choice: A

then

Question: What is the plural of eye?

A.Eyed B.Ice C.Eyeses D.Eyes

Answer:D

Correct!

----------------------------------

using this header

#include<stdio.h>
#include<conio.h>
#include<ctype.h> (OPTIONAL)
main()
{



i have started the program but i keep messing it up. pls help me.
Last edited on
Here

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
#include <iostream>
#include <stdlib.h>
#include <conio.h>

using namespace std;

char ppalMenu[]="choose a subject\n\na. English\nb. Math\nc. Science\n\nChoice: ";
char englishQuestion[]="Question: What is the plural of eye?\n\na. Eyed\nb. Ice\nc. Eyeses\nd. Eyes\n\nAnswer: ";
char mathQuestion[]="Question: in x+3=6 x=?\n\na. 1\nb. -3\nc. 3\nd. 2\n\nAnswer: ";
char scienceQuestion[]="";//You do it

char option;

int main()
{
  cout<< ppalMenu;
  
  do {
    option=getch();    
  } while (option!='a' && option!='b' && option!='c');
  
  cout<< option << endl << endl;
  
  switch(option){
    case 'a':
      cout<< englishQuestion;
      do {
        option=getch();    
      } while (option!='a' && option!='b' && option!='c' && option!='d');
      cout<< option << endl << endl;
      if(option=='d'){
            cout<< "Correct!";
      }else{
            cout<< "Wrong answer";
      }
      break;
    case 'b':
      cout<< mathQuestion;
      do {
        option=getch();    
      } while (option!='a' && option!='b' && option!='c' && option!='d');
      cout<< option << endl << endl;
      if(option=='c'){
            cout<< "Correct!";
      }else{
            cout<< "Wrong answer";
      }
      break;
    case 'c':
      //You do it
      break;
  }
  
  getch();	
  return 0;
}
Last edited on
Ahaha, gaorozcoo beat me to it! lol!
(i need to type faster)
But, yeah good example.
jejeje

Thanks.
Topic archived. No new replies allowed.