help with an assignment

So I have been trying to create a program to match the requirments given in ym current assignment.
Write a program that quizzes students on simple integer arithmetic problems involving addition, subtraction, multiplication, or division.

The tutor begins by prompting the user for the difficulty of the problem by choosing the number of digits (1, 2, 3, or 4).

Next the program begins a loop which display a menu allowing the user to select addition, subtraction, multiplication, division, or quit (for the user to quit the program).

The program display a problem with two random positive integers and the chosen arithmetic operator.

The program pauses while the student works on the problem.

When the student is ready to check the answer, he or she can press any key and the program will display the correct answer.

The program returns to beginning of the loop by displaying the menu again.

Other Requirements:
1. Allow the user to choose the number of digits only once. The maximum number of digits should be 4 (error checking required)
2. Display a menu of arithmetic operators continues to loop until user chooses option to quit. (error checking required)
3. Display each problem using a vertical format with all digits aligned. (See examples below)
4. Display appropriate arithmetic operators for tutoring beginning math students:
5. (+) Addition, (-) Subtraction, (x) Multiplication, (÷) Division, and (─) Line.
6. (ASCII character 196 is used for line, ASCII Character 246 for division operator, lower case x for multiplication operator)
7. For division, integer division should be used. The result should display the integer value with remainder (modulus) marked as a "R" and the remainder.
8. All problems should involve positive integers.

I am really new to this and am completely at a loss, I can't get to the next step of having it recognize a level selection and displaying a problem to be solved, accepting an answer and repeating.... yeah I am dense for sure at this.
so far i have a menu that allows selections from the second menu and repeats any other steps i tried crashed and burned.
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
#include <cstdlib>
#include <iostream> 
using namespace std;

int main()
{
  int option;
  int mlevel;
	int dlevel;
	int slevel;
	int alevel;
	int choice;
	int answer;
	int key;


  do //do-while loop starts here.that display menu again and again until user select to exit program
  { 
     //Displaying Options for the menu
    cout << "Please choose one of the following options:" << endl;
				cout << " [1] Addition" << endl;
				cout << " [2] Subtraction" << endl;
				cout << " [3] Multiplication" << endl;
				cout << " [4] Division" << endl;
				cout << " [5] Quit" << endl;
			
				
    
     cin >> key;  // taking option value as input and saving in variable "option"
     
     if(key == 1) // Checking if user selected option 1
     {
				cout << " level [1] " << endl;
				cout << " level [2] " << endl;
				cout << " level [3] " << endl;
				cout << " level [4] " << endl;
				cin >> alevel;
       
     }

     else if(key == 2) // Checking if user selected option 2
     {
			cout << " [1] " << endl;
				cout << " [2] " << endl;
				cout << " [3] " << endl;
				cout << " [4] " << endl;
				cin >> slevel;
     }
     else if(key == 3) // Checking if user selected option 3
     {
				cout << " [1] " << endl;
				cout << " [2] " << endl;
				cout << " [3] " << endl;
				cout << " [4] " << endl;
				cin >> mlevel;
     }
     else if(key == 4) // Checking if user selected option 4
     {
				cout << " [1] " << endl;
				cout << " [2] " << endl;
				cout << " [3] " << endl;
				cout << " [4] " << endl;
				cin >> dlevel;
     }
    
  
				
	  
		
					}while(key != 5);  //condition of do-while loop
   
   return 0;
}

if (key == 1 && alevel == 1){
(answer = 2);
cout<< "1 + 1 = "<<"? ";
cin >> response;
if (response == answer){
cout << "correct";}
Something like this? Ive tried this and can't make it work..... I don't even know if i'm close
What are you having problems with exactly? Right now you only have a menu.
Yes, my issue is despite reading through the text, everything I am trying to accomplish a situation of key ==1 && alevel ==1 as a condition for displaying a problem and setting the answer is failing to loop or display.
1
2
3
4
5
6
7
8
9
10
if(key == 1) // Checking if user selected option 1
     {
				cout << " level [1] " << endl;
				cout << " level [2] " << endl;
				cout << " level [3] " << endl;
				cout << " level [4] " << endl;
				cin >> alevel;
                                // You don't have anything written after the user inputs alevel
                                // You can do nested if/else or switch cases.
     }
what is wrong with this? Any ideas?
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
#include <cstdlib>
#include <iostream> 
using namespace std;

int main()
{
	int aanswer;
	int sanswer;
	int	manswer;
	int	danswer;
	int option;
	int mlevel;
	int dlevel;
	int slevel;
	int alevel;
	int choice;
	int key;


  do //do-while loop starts here.that display menu again and again until user select to exit program
  { 
     //Displaying Options for the menu
    cout << "Please choose one of the following options:" << endl;
				cout << " [1] Addition" << endl;
				cout << " [2] Subtraction" << endl;
				cout << " [3] Multiplication" << endl;
				cout << " [4] Division" << endl;
				cout << " [5] Quit" << endl;
			
				
    
     cin >> key;  // taking option value as input and saving in variable "option"
     
     if(key == 1) // Checking if user selected option 1
     {
				cout << " level [1] " << endl;
				cout << " level [2] " << endl;
				cout << " level [3] " << endl;
				cout << " level [4] " << endl;
				cin >> alevel;
       
     }

     else if(key == 2) // Checking if user selected option 2
     {
			cout << " [1] " << endl;
				cout << " [2] " << endl;
				cout << " [3] " << endl;
				cout << " [4] " << endl;
				cin >> slevel;
     }
     else if(key == 3) // Checking if user selected option 3
     {
				cout << " [1] " << endl;
				cout << " [2] " << endl;
				cout << " [3] " << endl;
				cout << " [4] " << endl;
				cin >> mlevel;
     }
     else if(key == 4) // Checking if user selected option 4
     {
				cout << " [1] " << endl;
				cout << " [2] " << endl;
				cout << " [3] " << endl;
				cout << " [4] " << endl;
				cin >> dlevel;
     }
    
  
				if (key ==1){ 
					if (alevel ==1){
						answer = 2;
						cout<< "1 + 1 = "<<"? ";
				cin >> aanswer;
				if (aanswer==answer){
						cout << "correct";}
				
			if (aanswer!=answer){
					cout << "incorrect ";}
					
					if(alevel ==2){
						answer = 3;
						cout<< "1 + 2 = "<<"? ";
				cin >> aanswer;
				if (aanswer==answer){
						cout << "correct";}
					
			if (aanswer!=answer){
					cout << "incorrect ";}
					
					if (alevel ==3){
						answer = 4;
						cout<< "1 + 3 = "<<"? ";
					cin >> aanswer;}
			if (aanswer==answer){
						cout << "correct";}
						
			if (aanswer!=answer){
					cout << "incorrect ";}
					
					if (alevel ==4){
						answer = 1;
				cout<< "1 + 0 = "<<"? ";
				cin >> aanswer;
			if (aanswer == answer){
					cout << "correct";}
					
			if (aanswer!=answer){
					cout << "incorrect ";}
					}
					}
					}	
					}
						while(key != 5);  //condition of do-while loop
   
   return 0;
}
This block of code has incorrect curly bracket placement.

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
    if (key ==1){ 
					if (alevel ==1){
						answer = 2;
						cout<< "1 + 1 = "<<"? ";
				cin >> aanswer;
				if (aanswer==answer){
						cout << "correct";}
				
			if (aanswer!=answer){
					cout << "incorrect ";}
			// Should have curly bracket here to end if (alevel ==1)
					if(alevel ==2){
						answer = 3;
						cout<< "1 + 2 = "<<"? ";
				cin >> aanswer;
				if (aanswer==answer){
						cout << "correct";}
					
			if (aanswer!=answer){
					cout << "incorrect ";}
			// Should have curly bracket here to end if (alevel ==2)		
					if (alevel ==3){
						answer = 4;
						cout<< "1 + 3 = "<<"? ";
					cin >> aanswer;} // unnecessary curly bracket 
			if (aanswer==answer){
						cout << "correct";}
		
			if (aanswer!=answer){
					cout << "incorrect ";}
			// Should have curly bracket here to end if (alevel ==3)	
					if (alevel ==4){
						answer = 1;
				cout<< "1 + 0 = "<<"? ";
				cin >> aanswer;
			if (aanswer == answer){
					cout << "correct";}
					
			if (aanswer!=answer){
					cout << "incorrect ";}
                       // Should have curly bracket here to end if (alevel ==4)
					
					
    }	// curly bracket for if(key==1)
} // curly bracket for the end of the do-while 
Last edited on
Thanks a million friend :)
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/209428/
Topic archived. No new replies allowed.