Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Absolute Calculator - (Full Of Bugs)- By CyberSpy

Finished making your own program (thats not part of the practicing forums) ? Show it off here

Absolute Calculator - (Full Of Bugs)- By CyberSpy

Postby cyberspy on Sun Sep 13, 2009 6:06 am

Although there are many calculators out there, but none of them was like actual one,
so this is one i have made, although full of bugs, but would work, must try out.

Thanks for having a Look.


Code: Select all
    #include <iostream>
    #include <string>

    using namespace std;

int main()
{
   cout<<"Welcome To The Calculator Full Of Bugs\nBut this is how the actual calculator should work";
        cout<<"\n\t\tBy CyberSpy\n";
   char oprator;
   int val1, val2;
   cout<<"\n\n\nSo What Your Waiting For Start Calculating\n\n\nNote-This Only accepts 2 arguments\n\n\n";
Stuff:
   cout<<endl;
   cin>>val1>>oprator>>val2;
   switch (oprator)
   {
      case '%':
      {
         cout<<"="<<val1%val2;
         goto Stuff;
         break;
      }
      case '/':
      {
         cout<<"="<<val1/val2;
         goto Stuff;
         break;
      }
      case '*':
      {
         cout<<"="<<val1*val2;
         goto Stuff;
         break;
      }
      case '+':
      {
         cout<<"="<<val1+val2;
         goto Stuff;
         break;
      }
      case '-':
      {
         cout<<"="<<val1-val2;
         goto Stuff;
         break;
      }
      default:
      {   
         cout<<"\nSyntax Error!!!\n";
         goto Stuff;
           break;
      }
   }
   
   system("pause");
   return 0;
}
cyberspy
 
Posts: 12
Joined: Sun Sep 13, 2009 4:14 am

Re: Absolute Calculator - (Full Of Bugs)- By CyberSpy

Postby glinka57 on Sun Sep 13, 2009 10:17 am

Lovely, you are right, this is a real calc. I found 3 bugs..

if you
enter a+b
then a+b+c
then x*y it spins off into a syntaxx error infinite loop.

It doesnt test for and block division by zero operations before the are sent for calculation.
eg: if(divisor==0)cout<<"WTH no division by zero "; ..then loop back to cin << divisor;
just type it before you get to answer = x/y; because that line will cause the error.

if I enter garbage, it just infinite loops. so maybe you could set up some checks for if(input != 1 || input != 2) etc etc
up unti all the possible characters you want your calc to acknowledge...

good job though, this is the first real calc.. of sorts
User avatar
glinka57
 
Posts: 195
Joined: Fri Feb 27, 2009 7:32 pm

Re: Absolute Calculator - (Full Of Bugs)- By CyberSpy

Postby cyberspy on Tue Sep 15, 2009 12:52 pm

thanks
cyberspy
 
Posts: 12
Joined: Sun Sep 13, 2009 4:14 am


Return to Full programs

Who is online

Users browsing this forum: No registered users and 0 guests

cron