Professional Documents
Culture Documents
for (;;){ do { cout<<"Welcome to thejoshcalculator. V1.5\n"; cout<<"Please choose an option by entering the number, press q to quit\n"; cout<<"1 - Addition\n"; cout<<"2 - Subtraction\n"; cout<<"3 - Division\n"; cout<<"4 - Multiplication\n"; cout<<"5 - Help\n"; cout<<"6 - About This Program\n"; cout<<"7 - Updates to this program\n"; cin>>choice; } while ( choice < '1' || choice > '7' && choice != 'q'); if (choice == 'q') break; switch (choice) { case '1': cout<<"Please enter a number\n"; cin>>num; cout<<"Another number to be added\n"; cin>>num2; cout<<num + num2; cout<<"\n"; break; case '2': cout<<"Please enter a number\n"; cin>>num; cout<<"Another number to be subtracted\n"; cin>>num2; cout<<num - num2; cout<<"\n"; break; case '3': cout<<"Please enter a number\n"; cin>>num; cout<<"Another one to be divided\n"; cin>>num2;
cout<<num / num2; cout<<"\n"; break; case '4': cout<<"Please enter a number\n"; cin>>num; cout<<"Another one to be multiplied\n"; cin>>num2; cout<<num * num2; cout<<"\n"; break; case '5': cout<<"This is a simple calculator made by me - Josh.\n"; cout<<"To select an option, type the number next to the option and press enter\n"; cout<<"E.G. for division, you would type 3 and press enter.\n"; cout<<"\n"; break; case '6': cout<<"thejoshcalculator, made by Joshua Griggs - Copyright 2007. :)\n"; cout<<"Feedback would be nice - joshieboy06@hotmail.com also, what programmes\n"; cout<<"do people need. Please give me ideas for programs. Bye!!\n"; cout<<"\n"; break; case '7': cout<<"Updates include: -double variable instead of int, so that decimals can be used.\n"; cout<<" -do while loop so that you can exit the program yourself\n"; cout<<"\n"; break; default: cout<<"That is not an option"; } } return 0;
}
C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Home Forums Programming Web Development Tutorials Snippets Blogs Freelance Jobs Lounge Login Join for Free!
Programmi ng Help
Search
Updated!
w00t
C and C++ VB6 Java VB.NET C# ASP.NET PHP ColdFusion Perl and Python Ruby Databases Other Languages Game Programmi ng Mobile Developme nt Software Developme
Go
Be Social
C++ Tutorials
of C++ experts, tutorials, code snippets, and more! There are 2,266 people online right now. Registration is fast and
Web Developme nt
It uses the switch statement. Thanks to Horace in the community who helped me What's correct the error of my ways Here? in the program. Btw, this is Members: only a very simple calculator 307,033 and can only calculate two Replies: 841,531 numbers at a time. Now it Reference Topics: uses a loop and quits when Sheets 140,625 Snippets: you want it to 4,466
FREE... Join Now! Web Developme nt HTML & Chat LIVE CSS With a C++ Expert JavaScript Graphic Design Flash & ActionScri C++ calculator pt Blogging This code (program) allows SEO & Advertising you to choose what Web Servers & calculations you want. Like Hosting Addition and Multiplication. Site Check
Data Structures In C++ Tutorial C++ Quick Reference Sheet (Cheat Sheet) Making a 2D Game Engine Using OpenGL - Part3 is up C++ Vector Tutorial CPP with ODBC (Open Database Connectivity) Converting and Evaluating Infix, Postfix and Prefix Expressions in C Getting Started In Microsoft Visual Studio 2008 Object Oriented Programming (oop) Tutorial Understanding Loops in C++ Producing Random Numbers 189 More C++ Tutorials...
Tutorials: 1,166
Actions:
Rating:
Rate this snippet!
Views: 42,591
Language: C++
Last Modified: February 8, 2007 Instructions: N/A
C++ Snippets
Snippet
1. #include <cstdlib> 2. #include <iostream> 3. 4. using namespace std; 5. 6. int main() 7. { 8. double num; 9. double num2; 10. char choice; 11. for (;;){ 12. do { 13. cout<<"Welcome to thejoshcalculator. V1.5\n"; 14. cout<<"Please choose an option by entering the number, press q to quit\n"; 15. cout<<"1 Addition\n"; 16. cout<<"2 Subtraction\n"; 17. cout<<"3 Division\n"; 18. cout<<"4 Multiplication\n"; 19. cout<<"5 Help\n"; 20. cout<<"6 About This Program\n";
Linked List Class Convert cases of strings Getting Current Directory Recursive Fibonacci Sequence Insertion Sort Example Shortest Function to Reverse a String ( Uses Recursion ) integer to string conversion C++ Int to String Convert characters into a ASCII value and vice versa Finding Square Root without using sqrt() 668 More C++ Snippets...
DIC Chatroom
Join our IRC 21. cout<<"7 Chat Updates to this program\n"; 22. cin>>choice; Bye Bye Ads 23. } while ( choice < '1' || choice > '7' && choice != 'q'); 24. if (choice == 'q') break; 25. switch (choice) Monthly { Drawing 26. case '1': 27. cout<<"Please enter a number\n"; 28. cin>>num; 29. Top cout<<"Another number to Contributors be added\n"; 30. Top 10 Kudos This Month cin>>num2; 31. erik.price (250) cout<<num + num2; Dogstopper 32. (175) cout<<"\n"; Anarion (175) 33. s3thst4 (125) break; Jaakuuta (125) 34. case macosxnerd10 '2': 1 (100) 35. ImaSexy (100) cout<<"Please enter a syfran (75) number\n"; EdwinNameles 36. s (75) cin>>num; rishabhsharma 37. (50) cout<<"Another number to be subtracted\n"; 38. cin>>num2; 39. cout<<num - num2; 40. cout<<"\n"; Powered by 41. Translate break;
42. case '3': 43. cout<<"Please enter a number\n"; 44. cin>>num; 45. cout<<"Another one to be divided\n"; 46. cin>>num2; 47. cout<<num / num2; 48. cout<<"\n"; 49. break; 50. case '4': 51. cout<<"Please enter a number\n"; 52. cin>>num; 53. cout<<"Another one to be multiplied\n"; 54. cin>>num2; 55. cout<<num * num2; 56. cout<<"\n"; 57. break; 58. case '5': 59. cout<<"This is a simple calculator made by me Josh.\n"; 60. cout<<"To select an option, type the number next to the option and press enter\n";
61. cout<<"E.G. for division, you would type 3 and press enter.\n"; 62. cout<<"\n"; 63. break; 64. case '6': 65. cout<<"thejoshcalculator , made by Joshua Griggs - Copyright 2007. :)\n"; 66. cout<<"Feedback would be nice joshieboy06@hotmail.com also, what programmes\n"; 67. cout<<"do people need. Please give me ideas for programs. Bye!!\n"; 68. cout<<"\n"; 69. break; 70. case '7': 71. cout<<"Updates include: -double variable instead of int, so that decimals can be used.\n"; 72. cout<<" -do while loop so that you can exit the program yourself\n"; 73. cout<<"\n"; 74. break; 75. default: 76. cout<<"That is not an
option"; 77. 78. 79. 80. } 81. return 0; 82. 83. 84. }
Comments
t_deshpande 2008-10-01 00:54:12 thanx Timemaster25 2008-11-26 08:55:00 Thank you so much for the base of C++. This was the first type of program I have made and what I did to learn about how to make C++ is take the script apart and try to understand what each thing does. Mayur342 2008-12-23 05:33:05 Hi josh.. I want a simple calculator programme which do not contain any function. And this calculator perform all operation on 2 variable and after performing the one operation the user can ask about continue or exit if the usr say yes then this programme perform next
operation on same value..pls give this programme...as early as possible thank you... jaber 2009-02-02 23:43:16 Thanks a lot for the calculator of c++. krich87 2009-03-17 15:37:09 Thanks a lot for this snippet, I was going in the total wrong direction with my C++ calculator, seeing this helped a lot. Nelyn 2009-06-30 03:00:25 wow r u a programmer i want to be like u i hope im bcome of wat u r ryt now;; god bless i'm an IT studEnt from philippines.. do u have facebook just add me up -dhimple_gemini05@yahoo.com-hakeem libya 2009-07-06 10:34:55 i want make sin function
Add comment
You must be registered and logged on to </dream.in.code> to leave comments.
Forum Index: Programming Help | C and C++ | VB6 | Java | VB.NET | C# | ASP.NET | PHP | ColdFusion | Perl and Python | Ruby | Databases | Other Languages | Game Programming | Mobile Development | Software Development | Computer Science | Industry News | Programming Tutorials | C++ Tutorials | Visual Basic Tutorials | Java Tutorials | VB.NET Tutorials | C# Tutorials | Linux Tutorials | PHP Tutorials | ColdFusion Tutorials | Windows Tutorials | HTML/JavaScript Tutorials | CSS Tutorials | Flash Tutorials | Web Promotion Tutorials | Graphic Design & Photoshop Tutorials | Software Development Tutorials | Database Tutorials | Other Language Tutorials | ASP.NET Tutorials | Game Programming Tutorials | WPF & Silverlight Tutorials | Copyright 2001-2008 MediaGroup1 LLC, All Rights Reserved A MediaGroup1 LLC Production - Version 6.0.2.1.36 Server: secure2