#include <iostream> std::cout << "Result: " << a * b << std::endl;
}
void displayMenu() {
std::cout << "Math Counting Tool" << std::endl; void division() {
std::cout << "1. Count Up" << std::endl; double a, b;
std::cout << "2. Addition" << std::endl; std::cout << "Enter two numbers to divide (numerator and
denominator): ";
std::cout << "3. Subtraction" << std::endl;
std::cin >> a >> b;
std::cout << "4. Multiplication" << std::endl;
if (b != 0) {
std::cout << "5. Division" << std::endl;
std::cout << "Result: " << a / b << std::endl;
std::cout << "6. Exit" << std::endl;
} else {
std::cout << "Choose an option: ";
std::cout << "Error: Division by zero!" << std::endl;
}
}
}
void countUp(int limit) {
std::cout << "Counting up to " << limit << ":" << std::endl;
int main() {
for (int i = 1; i <= limit; ++i) {
int choice;
std::cout << i << " ";
do {
}
displayMenu();
std::cout << std::endl;
std::cin >> choice;
}
switch (choice) {
void addition() {
case 1: {
double a, b;
int limit;
std::cout << "Enter two numbers to add: ";
std::cout << "Enter the limit to count up to: ";
std::cin >> a >> b;
std::cin >> limit;
std::cout << "Result: " << a + b << std::endl;
countUp(limit);
}
break;
}
void subtraction() {
case 2:
double a, b;
addition();
std::cout << "Enter two numbers to subtract: ";
break;
std::cin >> a >> b;
case 3:
std::cout << "Result: " << a - b << std::endl;
subtraction();
}
break;
case 4:
void multiplication() {
multiplication();
double a, b;
break;
std::cout << "Enter two numbers to multiply: ";
case 5:
std::cin >> a >> b;
division();
break;
case 6:
std::cout << "Exiting the program." << std::endl;
break;
default:
std::cout << "Invalid choice. Please try again." <<
std::endl;
}
} while (choice != 6);
return 0;
}