// Junior High Calculator v1.3 BETA // This is the second version given to beta testers. // This is the first version using Michael's (my brother's) suggestion about recursion. #include int main() { unsigned long choice; float numOne; float numTwo; float ans; unsigned long ansremain; unsigned long divOne; unsigned long divTwo; unsigned long remain; unsigned long trione; unsigned long tritwo; unsigned long trithree; int two = 2; int four = 4; using std::cout; using std::cin; cout << "Junior High Calculator v1.3 BETA \n Created By: Brian DeFreitas\n"; cout << "\nEnter a number choice. Your choices are:\n 1. Add\n 2. Subtract\n 3. Multiply\n"; cout << " 4. Divide with Decimal\n 5. Divide with Remainder\n 6. Area of a Triangle\n"; cout << " 7. Area of a Rectangle\n 8. Area of a Square\n 9. Perimiter of a Triangle\n"; cout << " 10. Perimiter of Rectangle\n 11. Perimiter of Square\n 12. Instructions\n\n"; cout << "Note: You should use this program ONLY to check your answers. Computers, like humans, mess up occasionally.\n"; cout << "#: "; cin >> choice; cout << "\nYour choice: " << choice; if (choice == 1) { cout << "\n\nEnter First Number: "; cin >> numOne; cout << "\nEnter Second Number: "; cin >> numTwo; (ans = numOne + numTwo); cout << "\nSum: " << ans << "\n\n"; } else if (choice == 2) { cout << "\n\nEnter First Number: "; cin >> numOne; cout << "\nEnter Second Number: "; cin >> numTwo; (ans = numOne - numTwo); cout << "\nDifference: " << ans << "\n\n"; } else if (choice == 3) { cout << "\n\nEnter First Number: "; cin >> numOne; cout << "\nEnter Second Number: "; cin >> numTwo; (ans = numOne * numTwo); cout << "\nProduct: " << ans << "\n\n"; } else if (choice == 4) { cout << "\n\nEnter First Number: "; cin >> numOne; cout << "\nEnter Second Number: "; cin >> numTwo; (ans = numOne / numTwo); cout << "\nQuotient: " << ans << "\n\n"; } else if (choice == 5) { cout << "\n\nEnter First Number: "; cin >> divOne; cout << "\nEnter Second Number: "; cin >> divTwo; (ansremain = divOne / divTwo); (remain = divOne % divTwo); cout << "\nQuotient: " << ansremain << " Remainder: " << remain << "\n\n"; } else if (choice == 6) { cout << "\n\nArea of a Triangle = Base times Height divided by Two."; cout << "\n\nEnter the Base: "; cin >> numOne; cout << "\nEnter the Height: "; cin >> numTwo; (ans = (numOne * numTwo) / two); cout << "\nArea of the Triangle is: " << ans << "\n\n"; } else if (choice == 7) { cout << "\n\nArea of a Rectangle = Length times Width."; cout << "\n\nEnter the Length: "; cin >> numOne; cout << "\nEnter the Width: "; cin >> numTwo; (ans = numOne * numTwo); cout << "\nArea of the Rectangle: " << ans << "\n\n"; } else if (choice == 8) { cout << "\n\nArea of a Square = Side times Side."; cout << "\n\nEnter One Side: "; cin >> numOne; (ans = numOne * numOne); cout << "\nArea of the Square: " << ans << "\n\n"; } else if (choice == 9) { cout << "\n\nPerimeter of a Triangle = Side + Side + Side."; cout << "\n\nEnter First Side: "; cin >> trione; cout << "\nEnter Second Side: "; cin >> tritwo; cout << "\nEner Third Side: "; cin >> trithree; (ans = trione + tritwo + trithree); cout << "Perimeter of Triangle: " << ans << "\n\n"; } else if (choice == 10) { cout << "\n\nPerimeter of a Rectangle = Length + Width times 2."; cout << "\n\nEnter the Length: "; cin >> numOne; cout << "\nEnter the Width: "; cin >> numTwo; (ans = (numOne + numTwo) * two) ; cout << "Perimeter of Rectangle: " << ans << "\n\n"; } else if (choice == 11) { cout << "\n\nPerimeter of a Square = Side times 4."; cout << "\n\nEnter One Side: "; cin >> numOne; (ans = numOne * four); cout << "Perimeter of Square: " << ans << "\n\n"; } else if (choice == 12) { cout << "\nInstructions: When you first open the program, you will be prompted for a number choice."; cout << "\nPick the number that corressponds with what you want to do."; cout << "\nFollow the Instructions to get your answer."; cout << "\nAfter Your Answer is displayed, the program will start over again."; cout << "\nIf you wish to use the program again, follow the prompts."; cout << "\nIf you do not, simply close the window."; cout << "\nHave Fun and Don't Cheat! \n\n"; } if (ans != 0) { return main(); } else return main(); }