-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaq3.cpp
More file actions
139 lines (122 loc) · 4.66 KB
/
Copy pathaq3.cpp
File metadata and controls
139 lines (122 loc) · 4.66 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
/*function to produce new questions for the student using srand and rand . */
void newque(int &m,int &n,int &flag)
{
if(flag==1)
{
m=rand()%10;
n=rand()%10;
}
else
{
m=rand()%((10*flag)-flag)+flag;
n=rand()%((10*flag)-flag)+flag;
}
}
/*function to choose the remarks for the student. */
void remarks(int &c)
{
c= (rand()%4) + 1 ;
}
int main()
{
/*m and n to store the two numbers of the question , ans to store the answer entered by the student , c to store the random remark for the student among the given one according to his/her performance , r and w to store the frequency of the correct and the wrong answers entered by the student and using flag to alter the number of digits according to the level . */
int m,n,ans,c,r=0,w=0,flag=1;
//to store the percentage of the student in each level.
double per=0.0 ;
cout<<"WELCOME TO THE WORLD OF DIGIT MULTIPLICATION IN MATHEMATICS!!"<<endl;
srand(time(NULL));
//labeling the point to use the goto statement.
again :
newque(m,n,flag);
cout<<"How much is "<<m<<" times "<<n<<" ? "<<endl;
//labeling the another point to use the goto statement.
begin:
/* Asking the input from the user as the answer of the questions. */
cin>>ans;
if(ans==(m*n))
{
r=r+1;
remarks(c);
/*choosing the random remark among the following. */
switch(c)
{
case 1 :
cout<<" Very good !\n "<<endl;
break;
case 2 :
cout<<" Excellent ! \n "<<endl;
break;
case 3:
cout<<" Nice Work !\n "<<endl;
break;
case 4:
cout<<" keep up the good work ! \n "<<endl;
break;
default:
cout<<"Never executed "<<endl;
}
/*if the frequency of the answers is equal to 10 the calculating the percentage of the student in the current level. */
if((r+w)==10)
{
mark :
per=(r*10);
/* If the percentage of the student in this level is greater than equal to 75 percent than promote the student to the next level. */
if(per>=75)
{
cout<<"\nCongratulations, you are ready to go to the next level ! "<<endl ;
cout<<"Your Percentage in this level is "<<per<<" % "<<endl ;
cout<<endl ;
cout<<"\nWELCOME TO THE NEXT LEVEL :) "<<endl ;
/*Promoting the flag to design the new question for the student. */
flag=flag*10 ;
/*Framing the new level for the student. */
newque(m,n,flag);
r=0;
w=0;
per=0.0;
}
else
{
cout<<"Please, Ask your teacher for help. "<<endl;
cout<<"As your percentage i.e "<<per<<"is less than 75 %. So, you should play this level again under the guidance of your teacher for your better performance."<<endl;
cout<<".................................ALL THE BEST....................................."<<endl ;
r=0;w=0;per=0.0;
}
}
goto again;
}
else
{
/*If student has entered the wrong answer then providing his/her the chances untill and unless he/she writes the right answer. */
w=w+1;
remarks(c);
/*choosing the random remark among the following. */
switch(c)
{
case 1 :
cout<<" No. Please Try again.\n"<<endl;
break;
case 2 :
cout<<" Wrong. Try once more.\n "<<endl;
break;
case 3:
cout<<" Don't give up ! \n"<<endl;
break;
case 4:
cout<<" No. Keep trying. \n "<<endl;
break;
default:
cout<<"Never executed "<<endl;
}
if((r+w)==10)
{
goto mark;
}
goto begin;
}
return 0;
}