Calculator Help

i wrote the code but i cant get it to restart and i don't get the wile loop's i need a little help
i am using c++ 2008 express edition it says i have 3 erors but i dont see any and it wont tell me what they are


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
// Include the iostream library 

#include <iostream> 

 

//Use the standard namespace 

using namespace std; 

 

void main ( ) 

{ 
   while (Guess= Forget_it)
   {

	   // Declare the variables 

	   float Number_1; 

	   float Number_2; 

	   float Result; 

	   int Which_Calculation;

	   int Restart = 1;

	   int Forget_it = 2;
	 

	   // Give instructions 

	   cout << "Choose a task. Press 1 to add, 2 to subtract, 3 to multiply, and 4 to divide." << endl; 

	   cin >> Which_Calculation; 

	 

	   // Get numbers 

	   cout << "Please enter the first number." << endl; 

	   cin >> Number_1; 

	   cout << "Please enter the second number." << endl; 

	   cin >> Number_2; 

	 

	   if (Which_Calculation == 1) 

	   { 

		  // Calculate the result 

		  Result = Number_1 + Number_2; 

	   } 

	    

	   if (Which_Calculation == 2) 

	   { 

		  // Calculate the result 

		  Result = Number_1 - Number_2; 

	   } 

	    

	   if (Which_Calculation == 3) 

	   { 

		  // Calculate the result 

		  Result = Number_1 * Number_2; 

	   } 

	    

	   if (Which_Calculation == 4) 

	   { 

		  // Calculate the result 

		  Result = Number_1 / Number_2; 

	   } 

	   // Print the answer is... 

	   cout << "The answer is..." << endl; 

	 

	   //Print the result 
	   cout << Result << endl; 
   }
	 cout << "Would You Like to Do Another Task ? < 1 for yes and 2 for no >." << endl;   
	 cin >> Guess;
	 
	 // 1 or 2
	 
	 if (Guess > Forget_it)
      {
         cout <<"Closing." << endl;
      }
	 
	 if (Guess > Restart)
      {
         cout <<"Restarting." << endl;
      }

	 system ("PAUSE"); 
   
}
 
Use int main() instead of void main() if you want to follow the ANSI/ISO standard.

At line 14 while (Guess= Forget_it) take a look at this http://www.cplusplus.com/doc/tutorial/operators/

Forget_it is declared inside the while loop and Guess isn't declared at all.
Last edited on
i figured it out by first making the wile loop then adding the calculator code

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
// Include the libraries
#include <iostream>
#include <ctime>
 
//Use the standard namespace
using namespace std;
 
void main ( )
{
   
   //Declare the variables
   int Pizza = 1;
   int Dog = 2;
   int Guess = 0;
 
   while (Guess != Dog)
   {
      //This code repeats until the condition is no longer true
   
	   // Declare the variables 

	   float Number_1; 

	   float Number_2; 

	   float Result; 

	   int Which_Calculation;

	   // Give instructions 

	   cout << "Choose a task. Press 1 to add, 2 to subtract, 3 to multiply, and 4 to divide." << endl; 

	   cin >> Which_Calculation; 

	 

	   // Get numbers 

	   cout << "Please enter the first number." << endl; 

	   cin >> Number_1; 

	   cout << "Please enter the second number." << endl; 

	   cin >> Number_2; 

	 

	   if (Which_Calculation == 1) 

	   { 

		  // Calculate the result 

		  Result = Number_1 + Number_2; 

	   } 

	    

	   if (Which_Calculation == 2) 

	   { 

		  // Calculate the result 

		  Result = Number_1 - Number_2; 

	   } 

	    

	   if (Which_Calculation == 3) 

	   { 

		  // Calculate the result 

		  Result = Number_1 * Number_2; 

	   } 

	    

	   if (Which_Calculation == 4) 

	   { 

		  // Calculate the result 

		  Result = Number_1 / Number_2; 

	   } 

	   // Print the answer is... 

	   cout << "The answer is..." << endl; 

	 

	   //Print the result 
	   cout << Result << endl;

      // Get the user's guess
      cout << "Would You Like to Do Another Task ? < 1 for yes and 2 for no >." << endl;
      cin >> Guess;
 
 
      //If the user guessed the right number, congratulate them
      if (Guess == Pizza)
      {
         cout <<"Restarting" << endl;
      }

	  //If the user guessed the right number, congratulate them
      if (Guess == Dog)
      {
         cout <<"Shutting Down" << endl;
      }
   }
   system ("PAUSE");
}
Topic archived. No new replies allowed.