Advertisement
Guest User

Fixed it

a guest
May 1st, 2010
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. int value[256];
  6. char operation;
  7. char continueno;
  8. bool firstpass = false;
  9. int total;
  10. int caculation(int number1, int number2)
  11. {
  12.     if(operation == '+')
  13.     {
  14.         return number1 + number2;
  15.     }
  16.         if(operation == '-')
  17.     {
  18.         return number1 - number2;
  19.     }
  20.         if(operation == '*')
  21.     {
  22.         return number1 * number2;
  23.     }
  24.         if(operation == '/')
  25.     {
  26.         return number1 / number2;
  27.     }
  28. }
  29.  
  30. int _tmain(int argc, _TCHAR* argv[])
  31. {
  32.  
  33.     for (;;)
  34.     {
  35.         if(firstpass = false)
  36.         {
  37.         cout << "Welcome to the C++ console tutorial with arrays\nThis is a custom tutorial to see how much I know in pointless console C++"
  38.         "\nEnjoy!\nPlease enter in your first value\n";
  39.         }
  40.         else{
  41.             cout << "Please enter in your first value";
  42.         }
  43.         cin >> value[1];
  44.         cout << "\nGood, now please enter in your second value";
  45.         cin >> value[2];
  46.         cout << "Good, now enter in a operation sign please.";
  47.         cin >> operation;
  48.         total = caculation(value[1],value[2]);
  49.         cout << "Your total is " << total << endl << "Would you like to try again?";
  50.         cin >> continueno;
  51.         if (continueno == 'y' || continueno == 'Y')
  52.         {
  53.             continue;
  54.             firstpass = true;
  55.         }
  56.                  break;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement