Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

how to make a modified calculator in C++ ???? please help ...

OpenStudy (anonymous):

@Callisto

OpenStudy (anonymous):

@dan815

OpenStudy (anonymous):

please help...

OpenStudy (dan815):

hi

OpenStudy (dan815):

what do u want ur calculator to do

OpenStudy (dan815):

do you need to make interface for a calculator?? or actually write functions for calculator operations

OpenStudy (anonymous):

yes

OpenStudy (anonymous):

actually write functions for calculator operations

OpenStudy (anonymous):

@dan815

OpenStudy (anonymous):

@mathslover

OpenStudy (anonymous):

@myininaya

OpenStudy (callisto):

Use math library, perhaps?

OpenStudy (callisto):

http://www.cplusplus.com/reference/cmath/

OpenStudy (anonymous):

calculator that perform this

OpenStudy (anonymous):

answer please

OpenStudy (callisto):

Can't see that clearly.

OpenStudy (anonymous):

wait

OpenStudy (anonymous):

OpenStudy (anonymous):

here's my answer but i don't know how put the loop #include <iostream> using namespace std; int main() { int a=0; char op; do { int number1, number2; cout <<a<<endl; cout << "Input a number: "; cin >> number1; cout << "Input a valid operator: "; cin >> op; cout << "Input another number: "; cin >> number2; switch (op) { case '+': cout << "The answer is: " << number1 + number2 << endl; break; case '-': cout << "The answer is: " << number1 - number2 << endl; break; case '*': cout << "The answer is: " << number1 * number2 << endl; break; case '/': cout << "The answer is: " << number1 / number2 <<endl; break; default: cout << "operator invalid." << endl; } cout<< "do you want to calculate again? (C or Q)"; cin >> op; } while (op == 'C'); return 0; }

OpenStudy (callisto):

How do you know how many input numbers / operators are there for "one calculation"?

OpenStudy (anonymous):

its depends to the users

OpenStudy (anonymous):

what should i do to perform more than 2 numbers and operation by using loop

OpenStudy (callisto):

while (op != '=')

OpenStudy (anonymous):

yes

OpenStudy (anonymous):

nice ka...

OpenStudy (anonymous):

thank you...

OpenStudy (callisto):

Huh? You got that?

OpenStudy (anonymous):

awwww.

OpenStudy (anonymous):

sorry there is still a lack...

OpenStudy (anonymous):

the number are only performing 2 numbers

OpenStudy (anonymous):

i need to perform 4 numbers in the second

OpenStudy (callisto):

lol, wait

OpenStudy (anonymous):

okok

OpenStudy (anonymous):

@ganeshie8

OpenStudy (anonymous):

@Callisto

OpenStudy (anonymous):

ok

OpenStudy (callisto):

It shouldn't work LOL

OpenStudy (callisto):

I think you need to rewrite your programme

OpenStudy (anonymous):

its still the same

OpenStudy (callisto):

I mean you need to *rewrite* your programme.

OpenStudy (anonymous):

can you help me??

OpenStudy (callisto):

I need to go soon...

OpenStudy (anonymous):

#include <iostream> using namespace std; void main () { char choice='C'; do{ char symbol1; int count = 1, result1=0; int x, y; cout<<"Initial value= "<<result1<<endl;// this will display the initial value to the user cout<<"Input number: ";//input the two integers cin>>x; cout<<"Input operation: "; cin>>symbol1; cout<<"Input number: "; cin>>y; switch (symbol1) { case '+': result1= x + y; break; case '-' : result1 = x-y; break; case '/': result1 = x/y; break; case '*': result1 = x*y; } int a, result = result1; char symbol ; do{ cout<<"Input operation: "; cin>>symbol; if (symbol == '=') continue; cout<<"Input number: "; cin>>a; count++; switch (symbol) { case '+': result = result + a; break; case '-': result = result -a; break; case '/': result = result /a; break; case '*': result = result *a; break; } }while(symbol!='='); cout<<"Result: "<<result<<endl; cout<<"[Q]Quit or [C]Repeat Program\n"; do{cin>>choice; }while(choice!='C'&&choice!='c'&&choice!='q'&&choice!='Q'); cout<<endl<<endl; }while(choice=='C'||choice=='c'); }

OpenStudy (anonymous):

please...

OpenStudy (anonymous):

Do the order of operations matter?

OpenStudy (callisto):

If you do multiplications and divisions first, then this programme should work. I believe this is not good though. Feel free to modify it. Ask if you have any questions.

OpenStudy (anonymous):

thanks :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!