Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Finished my calculator!

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Random spam
View previous topic :: View next topic  
Author Message
The Fish
Expert Cheater
Reputation: 3

Joined: 11 Aug 2008
Posts: 114
Location: Ohio bitch

PostPosted: Tue Feb 22, 2011 12:09 pm    Post subject: Finished my calculator! Reply with quote

Code:
// Calculator, by James Fisher

// Include the iostream library
#include <iostream>

//Use the standard namespace
using namespace std;

void main ( )
{
   // 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 << "And the answer is..." << endl;

   //Print the result
   cout << Result << endl;
   system ("PAUSE");
}


I happy.

_________________
It was nice while it lasted.
Back to top
View user's profile Send private message
SGL
Grandmaster Cheater
Reputation: 14

Joined: 04 May 2007
Posts: 758

PostPosted: Tue Feb 22, 2011 12:15 pm    Post subject: Reply with quote

I chose 4.
Number 1 will be 1.
Number 2 will be 0.
What happens?

_________________
I'm SirGodlike
Back to top
View user's profile Send private message
Channel GannoK
pffrt
Reputation: 130

Joined: 12 Apr 2008
Posts: 608

PostPosted: Tue Feb 22, 2011 12:54 pm    Post subject: Reply with quote

Good job. I made a calculator in Visual Basic the other day and it is similar.
_________________
Back to top
View user's profile Send private message
SGL
Grandmaster Cheater
Reputation: 14

Joined: 04 May 2007
Posts: 758

PostPosted: Tue Feb 22, 2011 1:02 pm    Post subject: Reply with quote

SGL loves MajjikelKitty wrote:
I chose 4.
Number 1 will be 1.
Number 2 will be 0.
What happens?

_________________
I'm SirGodlike
Back to top
View user's profile Send private message
Aniblaze
Grandmaster Cheater Supreme
Reputation: 138

Joined: 23 Apr 2006
Posts: 1757
Location: The Netherlands

PostPosted: Tue Feb 22, 2011 2:18 pm    Post subject: Reply with quote

Use a switch brother Smile. I made it so that it won't crash when a number outside of the given range is entered.

Code:
// Calculator, by James Fisher

// Include the iostream library
#include <iostream>

//Use the standard namespace
using namespace std;

void main ( )
{
   // 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;

   switch(Which_Calculation) {
      case 1:
         Result = Number_1 + Number_2;
      break;
      case 2:
         Result = Number_1 - Number_2;
      break;
      case 3:
         Result = Number_1 * Number_2;
      break;
      case 4:
         Result = Number_1 / Number_2;
      break;
      default:
         Result = 0;
      break;
   }

   // Print the answer is...
   cout << "And the answer is..." << endl;

   //Print the result
   cout << Result << endl;
   system ("PAUSE");
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Random spam All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites