#include <iostream> #include <cmath> #include <iomanip> #include <vector> #include <algorithm> using namespace std;
cout << "\n--- Prime Number Checker ---\n"; cout << "Enter a positive integer: "; cin >> num;
cout << fixed << setprecision(1);
cout << "\n--- Advanced Calculator ---\n"; cout << "1. Power (x^y)\n"; cout << "2. Square Root\n"; cout << "3. Sine (sin)\n"; cout << "4. Cosine (cos)\n"; cout << "5. Tangent (tan)\n"; cout << "Enter your choice: "; cin >> choice;
cout << fixed << setprecision(2); cout << "\n--- Results ---\n"; cout << "Sum: " << sum << endl; cout << "Average: " << average << endl; cout << "Minimum: " << minNum << endl; cout << "Maximum: " << maxNum << endl; }
do { showMenu(); cout << "Enter your choice (1-6, 0 to exit): "; cin >> choice; switch(choice) { case 1: basicCalculator(); break; case 2: advancedCalculator(); break; case 3: numberStats(); break; case 4: primeChecker(); break; case 5: temperatureConverter(); break; case 6: cout << "\nThank you for using the calculator!\n"; cout << "Exiting program...\n"; break; default: if(choice != 0) cout << "\nInvalid choice! Please try again.\n"; break; } if(choice != 6 && choice != 0) { cout << "\nPress Enter to continue..."; cin.ignore(); cin.get(); clearScreen(); } } while(choice != 6);
void advancedCalculator() { double num, result; int choice;
double average = sum / n;
switch(operation) { case '+': cout << "\nResult: " << num1 << " + " << num2 << " = " << num1 + num2 << endl; break; case '-': cout << "\nResult: " << num1 << " - " << num2 << " = " << num1 - num2 << endl; break; case '*': cout << "\nResult: " << num1 << " * " << num2 << " = " << num1 * num2 << endl; break; case '/': if(num2 != 0) cout << "\nResult: " << num1 << " / " << num2 << " = " << num1 / num2 << endl; else cout << "\nError: Division by zero!\n"; break; default: cout << "\nInvalid operator!\n"; } }
cout << fixed << setprecision(2);