| | |
arithmetic calculator
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I keep getting errors in my code. I can enter the first number 1 fine but then is says that letter c or a is not initialized. What am I doing wrong? This is what i have so far
C++ Syntax (Toggle Plain Text)
// Exercise 8.13: ComparingRates.cpp // Application that calculates the amount of money the user will have // after 10 years at several interest rates. #include <string> #include <iostream> #include <iomanip> using namespace std; void main ( ) { int choice; double a, b, c; char an; cout << "Please enter the operation you want" << endl; cout << "Press 1 for addition" << endl << "Press 2 for subtraction" << endl << "Press 3 for division" << endl << "Press 4 for multiplication" << endl; cin >> choice; cout << "Please enter the numbers you want to do calculation with" << endl; while (an = 'y') { if (choice == 1) { c = a + b ; } if (choice == 2) { c = a - b; } if (choice == 3) { c = a / b; } if (choice == 4) { c = a * b; } cout << "Here is your result: " << c << endl; cout << "want to do it again?" << endl; cin >> an; } } /************************************************************************** * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * **************************************************************************/
Knowledge is earned, Education is learned.- me
0
#2 31 Days Ago
Tell me if you see a problem here :
Then you say :
In which you don't do this :
char an; cout << "Please enter the operation you want" << endl; cout << "Press 1 for addition" << endl << "Press 2 for subtraction" << endl << "Press 3 for division" << endl << "Press 4 for multiplication" << endl; cin >> choice; cout << "Please enter the numbers you want to do calculation with" << endl; while (an = 'y')
Then you say :
C++ Syntax (Toggle Plain Text)
cout << "Please enter the numbers you want to do calculation with" << endl;
In which you don't do this :
C++ Syntax (Toggle Plain Text)
cin >> a >> b;
1) What word becomes shorter if you add a letter to it?
[ Solved by : niek_e, Paul Thompson, SgtMe, murtan, xavier666, jonsca]
2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
[*solved by : murtan, xavier666]
3) What is the 123456789th prime numer?![]() |
Similar Threads
- Simple Left-To-Right Arithmetic Calculator (C)
- help me please I try to make a arithmetic calculator but i have 3 errors (C++)
- Mamu help meeeeeeeeeeeeeeeeeeeee! (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: Change the file stream object's read position in C++.
- Next Thread: Apparent flaws in C++
| Thread Tools | Search this Thread |
api application array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete desktop developer directshow dll email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int integer java lib linux loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct studio template templates text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






