Heretic121 Posted March 20, 2014 Author Posted March 20, 2014 Is C++ code when your hot teacher tells you that you only have a C , but if you diddle her after school, you might get a C++? *sighs* 1 Quote
Midnight Posted March 20, 2014 Posted March 20, 2014 Is C++ code when your hot teacher tells you, with a wink and a gleam in her eye, that you only have a C , but if you diddle her after school, you might get a C++? Soul, I know that you are going back to school and as a friend and fellow FA member, I highly, highly encourage you to NOT do this. Okay? 1 Quote
Chameleon Posted March 20, 2014 Posted March 20, 2014 Is C++ code when your hot teacher tells you, with a wink and a gleam in her eye, that you only have a C , but if you diddle her after school, you might get a C++? This hahaha Quote
Heretic121 Posted March 20, 2014 Author Posted March 20, 2014 Gotta get ahead somehow, darnit! Work your ass off Oh wait... that was the problem in the first place. Just work... hard? Damn it, Soul! Quote
soulJAHmon Posted March 20, 2014 Posted March 20, 2014 Ok, fine... I'll "work it" very hard.......I got moves like Jagger Quote
Heretic121 Posted March 20, 2014 Author Posted March 20, 2014 Ok, fine... I'll "work it" very hard.......I got moves like Jagger Of course you have... .... ... Wait... how did we get so horribly off topic? Quote
Heretic121 Posted March 20, 2014 Author Posted March 20, 2014 See? This is why we can never have anything nice! You guys just thread hijacking all over the place. Quote
Midnight Posted March 20, 2014 Posted March 20, 2014 Clean it kind sir. Then we can resume or normal operations! Quote
Midnight Posted March 21, 2014 Posted March 21, 2014 Okay this is the start Heretic- IDK what the errors are, but I'll look at it after dinner. #include <iostream> int main() { double num1; char op; double num2; int pick; double answer; { std::cout << "Please enter your first number.\n"; std::cin >> num1 std::cout << "Please enter your second number.\n"; std::cin >> num2 std::cout << "Do you wish to add << "+" >> these numbers?\n"; std::cout << "Press y to add numbers or n to leave program.\n"; std::cin >> pick } if (pick == y) { answer = num1 + num2; std::cout << num1 << "+" << num2 "=" << answer << std::endl; } if (pick == n) { return 0; } Quote
Midnight Posted March 21, 2014 Posted March 21, 2014 Okay second try after a fresh look. LOL! #include <iostream> int main() { double num1; char op; double num2; int pick; double answer; { std::cout << "Please enter your first number.\n"; std::cin >> num1; std::cout << "Please enter your second number.\n"; std::cin >> num2; std::cout << "Please enter the operator you wish to use, choices +.\n"; std::cin >> op; if (op == '+') { answer = num1 + num2; std::cout << num1 << "+" << num2 << "=" << answer << std::endl; } } std::cout << "Press '1' to restart the program or '0' to quit. \n"; std::cin >> pick; if(pick == 1) { main (); } if(pick == 0) { return 0; } } Quote
Midnight Posted March 21, 2014 Posted March 21, 2014 Okay here I was going for the loop, but after entering either y or n it closes the program. Hmmph! #include <iostream> int main() { float Num1; float Num2; float Answer; int which_calculation; char again = 'y'; { std::cout << "Press 1 to add.\n"; std::cin >> which_calculation; std::cout << "Please enter your first number.\n"; std::cin >> Num1; std::cout << "Please enter your second number.\n"; std::cin >> Num2; } if (which_calculation == 1) { Answer = Num1 + Num2; } std::cout << "The answer is ...\n"; std::cout << Answer << std::endl; if (again == 'y') { std::cout << "again (y/n)?"; std::cin >> again; } } Quote
Heretic121 Posted March 21, 2014 Author Posted March 21, 2014 Little confused about the parenthesis on line 14 & 22 lol Also, you're not getting the user input for "answer" So "answer" is constantly "y" 1 Quote
Midnight Posted March 21, 2014 Posted March 21, 2014 Yes that is the issue that I was getting. It was driving me nuts. Also when I used while, it would ask me the same question or exit, can't remember which. But if I used n it would restart the process. Help me oh great one. Originally I had if (again == 'y') { std::cout << "again (y/n)?"; std::cin >> again; } before the rest of the script and it would just endlessly ask you if you wanted to do it again. Therefore I moved. Which lines are you talking about? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.