Question
#include #include using namespace std; //function prototypes void showMenu(); void help(); void arithmetic(); void relational(); void logical(); //main method int main() { char choice; //variable
#include
#include
using namespace std;
//function prototypes
void showMenu();
void help();
void arithmetic();
void relational();
void logical();
//main method
int main()
{
char choice; //variable to store user choice from menu
do
{
showMenu(); //function call to showMenu(), which displays menu for user
cin >> choice;
switch (choice) // switch statement for choice
{
case 'H':
help(); //call help() if user choice is H
break;
case 'A':
arithmetic(); // call arithemtic() if user choice is A
break;
case 'R':
relational(); // call relational() if user choice is R
break;
case 'L':
logical(); //call logical() if user choice is L
break;
case 'Q':
case 'q':
exit(0); //call exit(0) to Quit, if user choice is Q or q
default:
cout << "Invalid Choice. Try Again!" << endl; // print Invalid choice for other choices
}
}while (1);
return 0;
}
void showMenu() //function to display MENU
{
cout << "--------------------------------------------------------------------"< cout << "MENU" << endl; cout << "H: Help \t"; cout << "A: Arithmetic \t"; cout << "R: Relational \t"; cout << "L: Logical \t"; cout << "Q\\q: Exit " << endl; cout << "Enter your choice :"; } void help() //function to display HELP { cout << "--------------------------------------------------------------------"< cout << "Welcome to Help" << endl; cout << "This program demonstrates the use of arithmetic, relational and logical operators." << endl; cout << "select option 2 to perform arithmetic operation" << endl; cout << "select option 3 to use realtional operator" << endl; cout << "select option 4 to use logical operator" << endl; cout << "Press any key to continue...."< char wait = getch(); } void arithmetic() //function to perform ARithmetic operations { int x, y,ch; cout << "--------------------------------------------------------------------"< cout <<"Enter two integers:"< cin >> x >> y; cout <<"select operation: 1. Addition"< cin >> ch; if(ch==1){ //if ch==1, add two numbers and display the result cout<<"Addition of two numbers is: "<< (x+y)< cout << "Press any key to continue...."< char wait = getch(); } else{ //else display Invalid operation. cout<<"Invalid Operation"< cout << "Press any key to continue...."< char wait = getch(); //waiting for key stroke system("cls"); //clearing the screen } } void relational() //function to perform Realational operations { int x, y,ch; cout << "--------------------------------------------------------------------"< cout <<"Enter two integers(X and Y):"< cin >> x >> y; cout <<"select operation: 1. check less than(<)"< cin >> ch; if(ch==1){ //if ch==1, check X < Y and display the result if(x cout<< "X is lesser than Y"< else cout<< "Y is lesser than X"< cout << "Press any key to continue...."< char wait = getch(); } else{ //else display Invalid operation. cout<<"Invalid Operation"< cout << "Press any key to continue...."< char wait = getch(); //waiting for key stroke system("cls"); //clearing the screen } } void logical() //function to perform Logical operations { int x, y,ch; cout << "--------------------------------------------------------------------"< cout <<"Enter two integers(X and Y):"< cin >> x >> y; cout <<"select operation: 1. Logical AND (&)"< cin >> ch; if(ch==1){ //if ch==1, perform Logical AND and display the result cout<<"Result of Logical AND of two numbers is: "<< (x&y)< cout << "Press any key to continue...."< char wait = getch(); } else{ //else display Invalid operation. cout<<"Invalid Operation"< cout << "Press any key to continue...."< char wait = getch(); //waiting for key stroke system("cls"); //clearing the screen } } This code isn't workinf for me can someone identify the problem and fix it for me, Thanks!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started