Help on making a project!

Hi i would like to make a program for my school exams.This will be a Multiple choice questions.
I want the program to read the questions from a file (i.e textfile) and then one by one will be shown on screen. When the user will answer the question using a,b,c or d then the choice will be written somewhere so I can make some statistics at the end of the questions.

How can i make this project ?What am i going to use?
Can anyone please help me to start it and then i will do it by myself.

Thanks a lot.

PS : I am using the Dev C++ compiler,no gui
Last edited on
How about, you start your design and then ask some specific questions.

What you have asked would take half a day to explain :P
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
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include <stream.h>

using namespace std;

int showquestion()
{//shows the question on screen
    ifstream text1;
  
  text1.open ("question1.txt", ifstream::in);
  while (text1.good())
    cout << (char) text1.get();
  text1.close();
} 
  
int main()
{
    int exit;
    char a,b,c,d,choice;
    char next_exit;
    ifstream text1;
    ifstream text0;
      
  showquestion(); //call the procedure to show question
   
  cout<<("\n\n Please select (a-d) or s (skip) to next question \n");
  cout<<"\n\n";
choose : //Label used in invalid choice
   cin>>choice;  //waiting for user's choice
  
  
    if (choice == 'a')     //CASE OF SELECTION a
    {
        ofstream text0; //("default.txt");   //Names File as ofstream (for output to file)
        text0.open ("default.txt", ios::app);  
        text0 << "a"<<"\n";
        text0.close();
        cout<<("Done. Your choice is : a ");
        cout<<endl;
        }//end of if case
    else if (choice == 'b')       //CASE OF SELECTION b
    {
    ofstream text0; //("default.txt");   //Names File as ofstream (for output to file)
        text0.open ("default.txt",  ios::app);
        text0 << "b"<<"\n";
        text0.close();
        cout<<("Done. Your choice is : b ");
        cout<<endl;
        }//end of else if
    else if (choice == 'c')       //CASE OF SELECTION c
    {
    ofstream text0; //("default.txt");   //Names File as ofstream (for output to file)
        text0.open ("default.txt",  ios::app);
        text0 << "c"<<"\n";
        text0.close();
        cout<<("Done. Your choice is : c ");
        cout<<endl;
        }//end of else if
    else if (choice == 'd')       //CASE OF SELECTION d
    {
    ofstream text0; //("default.txt");   //Names File as ofstream (for output to file)
        text0.open ("default.txt",  ios::app);
        text0 << "d"<<"\n";
        text0.close();
        cout<<("Done. Your choice is : d ");
        cout<<endl;
        }//end of else if
    else if (choice == 's')       //CASE OF skipping question
    {
       cout<<("Question skipped ! :\n");
          text0.open ("default.txt",  ios::app);
 //         text0 << "skipped \n";
          text0.close();
          
       cout<<"Press N to go to the next question or E to EXIT. \n";    //SUB MENUS FOR EXIT OR GO TO NEXT
                    cin>>next_exit;
                    if  ((next_exit) == 'N' or (next_exit) == 'n')
                     {
                      cout<<"Proceed with the next question. \n";
                      //call the function with questions!
                      }
                    else if  ((next_exit) == 'E' or (next_exit) == 'e')
                      {
                      cout<<"Apllication Stopped. \n";
                      return 1;
                      }
       }//end of else if
  else cout<<("Invalid Choice.\n")<<("Select again. \n");
         goto choose;
/*

  return 0;
}
  */
This is the code i have written.
I know that it is so good and also the best method i used ,but i dont know how else to write the program
Please help me...
I want the program to read the questions one by one from the file,in the screen will be appeared the 1st question and then there will be a,b,c or from choices.when the user makes a selection by pressing a-d then the choice should be writen somewhere and then goes to the next question.Finally i would like to see the results i.e how many correct questions ,wrong questions.


thanks for your interest.i am a begginer in c++
The text with questions is named question1.txt and is like the following:

#1 Question

Here is the question!

a. Contents
b. Contents
c. Contents
d. Contents
ummm, your code looks pretty good as it is, but just to make it a much much simpler code, you can easily generate another function that sends the user's choice as an argument.

the function can then take that character, and write it to a file. that way, you don't have to repeat the code so many times.

also, i don't quite understand what you mean by "statistics" but if you mean whether or not you got it right, or how many questions you answered, you can easily keep track of that using a counter and a loop if necessary.

i hope you can understand those, if you don't please ask and i'll post some code but then it takes the fun out of writing the program out yourself right? (:
i think u sud use a function here...
with each correct answer call a function and then do the statistics....or whtever...u can also use loop to ask questions....
happy programmin though...
Topic archived. No new replies allowed.