+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Jan 2008
    Location
    PA
    Posts
    1,164
    Points
    4,029,076.25
    Rep Power
    221

    Default SonniE's Hex Calculator[C++]

    Made this in 10 mins on an all-nighter before school procrastinating =p
    Code:
    /*
      Name: Hex Calculator
      Author: SonniE
      Date: 02/06/08 05:25
      Description: SonniE's Custom Hex Calculator a www.codinghs.com Original
    */
    
    #include <iostream>
    #include <cmath>
    using namespace std;
    int main()
    {
        char ans, type;
        int val1, val2, result, lim;
         cout << "Welcome TO SonniE's Hex Calculator! A WWW.codinghs.COM Original\n";
         there:
         cout << "What Operation Would You Like Todo?\n 1) Add\n 2) Subtract\n 3) Divide\n 4) Multiply\n";
         cin >> type;
         if (type == '1')
         {
                  cout << "How Many Numbers Do You Want To Add?";
                  cin >> lim;
                  cout << "Enter 1st Number: ";
                  cin >> hex>>val1;
                  lim = lim -1;
                  result = val1;
                  while (lim >= 1)
                  {
                  lim = lim-1;
                  cout << "Enter Next Number: ";
                  cin>> hex >> val2;
                  result = result + val2;
                  }
                  cout << "Sum is: " << hex << result << "\n";
                  goto query;
         }
         else if (type == '2')
         {
              cout << "How Many Numbers Do You Want To Subtract?"; 
                  cin >> lim;
                  cout << "Enter 1st Number: ";
                  cin >> hex>>val1;   
                  lim = lim -1;
                  result = val1;
                  while (lim >=1)
                  {
                        lim = lim -1;
                        cout << "Enter Next Number: ";
                        cin>> hex >> val2;
                        result = result - val2;
                  }
                  cout << "Difference is: " << hex << result << "\n";
                  goto query;
         }
         else if(type == '3')
         {
              cout << "Enter 1st Number: ";
              cin >> hex>>val1;
              result = val1;
              cout << "Enter Next Number: ";
              cin>> hex >> val2;
              result = result / val2;
              cout << "Result is: " << hex << result << "\n";
              goto query;
         }
         else if(type == '4')
         {
              cout << "How Many Numbers Do You Want To Multiply?"; 
              cin >> lim;
              cout << "Enter 1st Number: ";
              cin >> hex>>val1;   
              lim = lim -1;
              result = val1;
              while (lim >=1)
              {
                    lim = lim -1;
                    cout << "Enter Next Number: ";
                    cin>> hex >> val2;
                    result = result * val2;
              }
              cout << "Product is: " << hex << result << "\n";
              goto query;
         }
    
    query:
         cout << "Do You Want Todo Another Calculation? (y/n)";
         cin >> ans;
         if (ans == 'y' || ans == 'Y')
         {
                 system("cls");
                 goto there;
         }
         else 
         {
         goto here;
         system("PAUSE");
         }
    here:
         return 0;
    }
    Attached Files


    Get Vip: »Here«
    Donate: »Here«
    >>List of Compilers<<
    >>SFDM Name Generator<<
    [Owner Of FluidCoding]

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts