solved

hi guys thanks for viewing and helping me out!!

here are the example what the things will looks like

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
       Enter problems per set: 3    

    Set #1
   
    What is the maximum number for this set? 100    

    45 + 21 = 66
    correct
    0 + 100 = 100    
    correct
    54 + 23 = 67
    incorrect
    
    Set #2
    ----------
    What is the maximum number for this set? 90

    59 - 19 = 40
    correct
    19 - 84 = -29    
    incorrect
    0 - 65 = -65
    correct

    Set #3
    ----------
    What is the maximum number for this set? 20
    0 * 18 = 0
    correct
    15 * 4 = 398
    incorrect
    8 * 17 = 873
    incorrect

    Set#1:  You got 2 correct out of 3 for 66.7%
    Set#2:  You got 2 correct out of 3 for 66.7%
    Set#3:  You got 1 correct out of 3 for 33.3%
    Overall you got 5 correct out of 9 for 55.6%


and we must have fixed int main which is

1
2
3
4
5
6
7
8
9
10
11
12
    int main()
    {
        <variable declarations>
        
        srand(static_cast<unsigned>(time(0)));    
        getProbsPerSet(<arguments>);  
        doOneSet(<no-more-than-3-arguments>);    
        doOneSet(<no-more-than-3-arguments>);
        doOneSet(<no-more-than-3-arguments>);
        printReport(<arguments>);
    }


so far i i've done with code with value of how many time it will repeated but i'm having some issue within set the randome number

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
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void getProbsPerSet(int); // let user choose how many time probs

void doOneSet(char, int); // do one set of each problem
void doOneProblem(int&); // ask user the answer
void checkAnswer(int, int); // compare the answer if it's right
void generateOperands(char&); // declare which calculation it needs
void CalculateCorrectAnswer(int, int, char, int&); // Find correct answer

int main() {
	int probsPerSet;

	getProbsPerSet(probsPerSet); // calling out getProbsPerSet
	srand(static_cast<unsigned>(time(0))); // generate randome number
	doOneSet('+', probsPerSet); // calling out doOneSet with character +
	doOneSet('-', probsPerSet); // calling out doOneSet with character -
	doOneSet('*', probsPerSet); // calling out doOneSet with character *

	system("pause");
	return 0;
}

void   getProbsPerSet(int probs) {  // Many will have fixed value now
	int probsPerSet;
	cout << "Enter problems per set: ";
	cin >> probsPerSet; // return Many as typed value
	return probsPerSet;
}

void doOneSet(char Function, int Many) {  // catches int Many, char Function from follwing than do doOneset
	int i;

	if (Function == '+') { // if when char +
		for (i = 0; i < Many; i++) { // repeat with following Many
			int First, Second, Answer, Final;
			First = rand() % 101; // generate randome number under 100
			Second = rand() % 101; // generate randome number under 100
			cout << First;  // show first generated number
			generateOperands(Function); // show which function we are in
			cout << Second << " = ";  // show second function and =
			doOneProblem(Answer); // ask for user to put value as answer
			CalculateCorrectAnswer(First, Second, Function, Final); // get the correct answer
			checkAnswer(Answer, Final); // compare with use's answer and right answer and show if it's right or wrong
		}
	}
	if (Function == '-') {  // if when char -
		for (i = 0; i < Many; i++) { // repeat with following Many
			int First, Second, Answer, Final;
			First = rand() % 101; // generate randome number under 100
			Second = rand() % 101; // generate randome number under 100
			cout << First;  // show first generated number
			generateOperands(Function); // show which function we are in
			cout << Second << " = ";  // show second function and =
			doOneProblem(Answer); // ask for user to put value as answer
			CalculateCorrectAnswer(First, Second, Function, Final); // get the correct answer
			checkAnswer(Answer, Final); // compare with use's answer and right answer and show if it's right or wrong
		}
	}
	if (Function == '*') { // if when char *
		for (i = 0; i < Many; i++) {  // repeat with following Many
			int First, Second, Answer, Final;
			First = rand() % 101; // generate randome number under 100
			Second = rand() % 101; // generate randome number under 100
			cout << First;  // show first generated number
			generateOperands(Function); // show which function we are in
			cout << Second << " = ";  // show second function and =
			doOneProblem(Answer); // ask for user to put value as answer
			CalculateCorrectAnswer(First, Second, Function, Final); // get the correct answer
			checkAnswer(Answer, Final); // compare with use's answer and right answer and show if it's right or wrong
		}
	}
}

void doOneProblem(int& Ans) {
	cin >> Ans;
}

void CalculateCorrectAnswer(int X, int Y, char F, int& A) { // generate correct answer with givin value X,Y with given function F than return A
	if (F == '+') {
		A = X + Y;
	}
	if (F == '-') {
		A = X - Y;
	}
	if (F == '*') {
		A = X * Y;
	}
}

void checkAnswer(int Ans, int A) { //compare right answer than user's answer than answer if it's right or wrong
	if (Ans == A) {
		cout << "Correct" << endl;
	}
	else {
		cout << "Incorrect" << endl;
	}
}

void generateOperands(char& F) { // just little trick for generate fixed function
	cout << " " << F << " ";
}

how can i set the randome number in here? and where can i put the setmaxnumber?

please help me out!!!
Last edited on
Hi,
Can you show us your current program output?
sure
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
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void getProbsPerSet(int&); // let user choose how many time probs
void doOneSet(char, int); // do one set of each problem
void doOneProblem(int&); // ask user the answer
void checkAnswer(int, int); // compare the answer if it's right
void generateOperands(char&); // declare which calculation it needs
void CalculateCorrectAnswer(int, int, char, int&); // Find correct answer

int main() {
	int probsPerSet;

	getProbsPerSet(probsPerSet);
	srand(static_cast<unsigned>(time(0)));
	doOneSet('+', probsPerSet);
	doOneSet('-', probsPerSet);
	doOneSet('*', probsPerSet);

	system("pause");
	return 0;
}

void   getProbsPerSet(int &Many) {
	cout << "Enter problems per set: ";
	cin >> Many;
}

void doOneSet(char Function, int Many) {
	int i;

	if (Function == '+') {
		for (i = 0; i < Many; i++) {
			int First, Second, Answer, Final;
			First = rand() % 101;
			Second = rand() % 101;
			cout << First;
			generateOperands(Function);
			cout << Second << " = ";
			doOneProblem(Answer);
			CalculateCorrectAnswer(First, Second, Function, Final);
			checkAnswer(Answer, Final);
		}
	}
	if (Function == '-') {
		for (i = 0; i < Many; i++) {
			int First, Second, Answer, Final;
			First = rand() % 101;
			Second = rand() % 101;
			cout << First;
			generateOperands(Function);
			cout << Second << " = ";
			doOneProblem(Answer);
			CalculateCorrectAnswer(First, Second, Function, Final);
			checkAnswer(Answer, Final);
		}
	}
	if (Function == '*') {
		for (i = 0; i < Many; i++) {
			int First, Second, Answer, Final;
			First = rand() % 101;
			Second = rand() % 101;
			cout << First;
			generateOperands(Function);
			cout << Second << " = ";
			doOneProblem(Answer);
			CalculateCorrectAnswer(First, Second, Function, Final);
			checkAnswer(Answer, Final);
		}
	}
}

void doOneProblem(int& Ans) {
	cin >> Ans;
}

void CalculateCorrectAnswer(int X, int Y, char F, int& A) {
	if (F == '+') {
		A = X + Y;
	}
	if (F == '-') {
		A = X - Y;
	}
	if (F == '*') {
		A = X * Y;
	}
}

void checkAnswer(int Ans, int A) {
	if (Ans == A) {
		cout << "Correct" << endl;
	}
	else {
		cout << "Incorrect" << endl;
	}
}

void generateOperands(char& F) {
	cout << " " << F << " ";
}

i'm still stuck in this
if you don't understand what i did here i just added comment 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
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
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void getProbsPerSet(int&); // let user choose how many time probs
void doOneSet(char, int); // do one set of each problem
void doOneProblem(int&); // ask user the answer
void checkAnswer(int, int); // compare the answer if it's right
void generateOperands(char&); // declare which calculation it needs
void CalculateCorrectAnswer(int, int, char, int&); // Find correct answer

int main() {
	int probsPerSet;

	getProbsPerSet(probsPerSet); // calling out getProbsPerSet
	srand(static_cast<unsigned>(time(0))); // generate randome number
	doOneSet('+', probsPerSet); // calling out doOneSet with character +
	doOneSet('-', probsPerSet); // calling out doOneSet with character -
	doOneSet('*', probsPerSet); // calling out doOneSet with character *

	system("pause");
	return 0;
}

void   getProbsPerSet(int &Many) {  // Many will have fixed value now
	cout << "Enter problems per set: ";
	cin >> Many; // return Many as typed value
}

void doOneSet(char Function, int Many) {  // catches int Many, char Function from follwing than do doOneset
	int i;

	if (Function == '+') { // if when char +
		for (i = 0; i < Many; i++) { // repeat with following Many
			int First, Second, Answer, Final;
			First = rand() % 101; // generate randome number under 100
			Second = rand() % 101; // generate randome number under 100
			cout << First;  // show first generated number
			generateOperands(Function); // show which function we are in
			cout << Second << " = ";  // show second function and =
			doOneProblem(Answer); // ask for user to put value as answer
			CalculateCorrectAnswer(First, Second, Function, Final); // get the correct answer
			checkAnswer(Answer, Final); // compare with use's answer and right answer and show if it's right or wrong
		}
	}
	if (Function == '-') {  // if when char -
		for (i = 0; i < Many; i++) { // repeat with following Many
			int First, Second, Answer, Final;
			First = rand() % 101; // generate randome number under 100
			Second = rand() % 101; // generate randome number under 100
			cout << First;  // show first generated number
			generateOperands(Function); // show which function we are in
			cout << Second << " = ";  // show second function and =
			doOneProblem(Answer); // ask for user to put value as answer
			CalculateCorrectAnswer(First, Second, Function, Final); // get the correct answer
			checkAnswer(Answer, Final); // compare with use's answer and right answer and show if it's right or wrong
		}
	}
	if (Function == '*') { // if when char *
		for (i = 0; i < Many; i++) {  // repeat with following Many
			int First, Second, Answer, Final;
			First = rand() % 101; // generate randome number under 100
			Second = rand() % 101; // generate randome number under 100
			cout << First;  // show first generated number
			generateOperands(Function); // show which function we are in
			cout << Second << " = ";  // show second function and =
			doOneProblem(Answer); // ask for user to put value as answer
			CalculateCorrectAnswer(First, Second, Function, Final); // get the correct answer
			checkAnswer(Answer, Final); // compare with use's answer and right answer and show if it's right or wrong
		}
	}
}

void doOneProblem(int& Ans) {
	cin >> Ans;
}

void CalculateCorrectAnswer(int X, int Y, char F, int& A) { // generate correct answer with givin value X,Y with given function F than return A
	if (F == '+') {
		A = X + Y;
	}
	if (F == '-') {
		A = X - Y;
	}
	if (F == '*') {
		A = X * Y;
	}
}

void checkAnswer(int Ans, int A) { //compare right answer than user's answer than answer if it's right or wrong
	if (Ans == A) {
		cout << "Correct" << endl;
	}
	else {
		cout << "Incorrect" << endl;
	}
}

void generateOperands(char& F) { // just little trick for generate fixed function
	cout << " " << F << " ";
}
Last edited on
Well, the program output is not code. It is basically something like this :

What is the maximum number for this set? 100    
45 + 21 = 66
correct
0 + 100 = 100    
correct
54 + 23 = 67
incorrect

etc


:)
Last edited on
ok sorry i wroted wrong i changed the question again please look one more time
http://www.cplusplus.com/forum/beginner/194382/
TheIdeasMan wrote:
Just a note for the future :+)

There also shouldn't be 2 topics about essentially the same subject. There is a risk that the same things will be said in both, possibly making it a time waster for those who reply.
Topic archived. No new replies allowed.