Sin
2012-05-23 10:42:44
First off, i'm absolutely amazed and thankful at how similar Delphi/Pascal script is to C++, should make my learning transition much easier.
First off, I want to know how to do a case statement in C++ -
as you can see, it looks a bit messy so I want to do a Simba-esque way (case cOperator of). Any help is appreciated!
First off, I want to know how to do a case statement in C++ -
//Calculator
#include <iostream>
using namespace std;
int main()
{
//Defining variables
char cMenu; //Menu?
char cOperator; //Operator (+,-,*,/)
int Num1; //X so to speak, first integer
int Num2; //Y, second integer
int y;
int i;
i = 2;
y = 6;
while(i = 2)
{ //this is basically a begin while the while statement is a n IF statement.
cout<<"/ny First Calculator, G to calc, x to exit:"; //writeLn basically
cin>>cMenu; //what this does is that it asks for an input, and stores it in cmenu
if (cMenu == 104) //G I believe
{
cout<<"enter a value an operator then a value pressing enter each time to use this";
}
else if (cMenu == 120) //this is x I believe
{
break; //kills the procedure
}
else if (cMenu == 103)
{
cin>>Num1;
cin>>cOperator;
cin>>Num1;
}
else
{
cout<<"neither of the options were selected, try again!"
} }
}
as you can see, it looks a bit messy so I want to do a Simba-esque way (case cOperator of). Any help is appreciated!