| | |
arithmetic calculator
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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 Nov 9th, 2009
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) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle. 2) Problem 2[b]solved by : jonsca
![]() |
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++
Views: 242 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll dynamic encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort stream string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






