Kindly convert the structure of the program from "if else if" statement to "switch" statement. /* Make a C++ program that will ask the user to select a specific arithmetic operation based on the options that will be shown in the program. Then, once the user will select  an operation, the program will ask the user to input two positive values. The program will immediately output the result of the selected operation.*/ #include using namespace std; int main(){      cout<< "roselyn centinales";          int select; float a, b, sum=0, diff=0, prod=0, quo=0, mod=0; BalikDiri:     cout<<"MENU:"<>select;     //if(condition)else if(condition) //nested if     if(select==1)     {         diri1:         cout<<" \n***ADDITION***"<>a>>b;                      if(a>=0 && b>=0){         sum=a+b;         cout<<"The sum is "<< sum <>a>>b;                  if(a>=0 && b>=0){             diff=a-b;             cout<<"The difference is "<< diff<>a>>b;                  if(a>=0 && b>=0){             prod=a*b;             cout<<"The product is "<< prod<>a>>b;                  if(a>=0 && b>=0){             quo=a/b;             cout<<"The quotient is "<< prod<>a>>b;         int x=a, y=b;         if(x>=0 && y>=0){             mod=x%y;             cout<<"The Modulud is "<< mod<

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Kindly convert the structure of the program from "if else if" statement to "switch" statement.

/* Make a C++ program that will ask the user to select a specific arithmetic operation
based on the options that will be shown in the program. Then, once the user will select 
an operation, the program will ask the user to input two positive values. The program
will immediately output the result of the selected operation.*/

#include<iostream>
using namespace std;
int main(){ 

    cout<< "roselyn centinales";
    
    int select;
float a, b, sum=0, diff=0, prod=0, quo=0, mod=0;

BalikDiri:
    cout<<"MENU:"<<endl;
    cout<<"[1] Addition\n";
    cout<<"[2] Subtraction\n";
    cout<<"[3] Multiplication\n";
    cout<<"[4] Division\n";
    cout<<"[5] Modulus\n";
    cout<<"[6] Exit\n";
    cout<<"Kindly press the number that corresponds to the operation of your choice."<<endl;
    cout<<"You've selected: ";
    
    
    cin>>select;
    //if(condition)else if(condition)
//nested if
    if(select==1)
    {
        diri1:
        cout<<" \n***ADDITION***"<<endl;
        cout<<"Input two positive values:"<<endl;
        cin>>a>>b;
            
        if(a>=0 && b>=0){
        sum=a+b;
        cout<<"The sum is "<< sum <<endl;
        system("pause");
        goto BalikDiri;
        
        
    }else{
        cout<<"Invalid input. Please enter positive values!!!!!";
        system("pause");
        system("cls");
        goto diri1;
        }
    
    }else if(select==2){
        forInvalidInput:
        cout<<"\n***SUBTRACTION***"<<endl;
        cout<<"Input two positive values:"<<endl;
        cin>>a>>b;
        
        if(a>=0 && b>=0){
            diff=a-b;
            cout<<"The difference is "<< diff<<endl;
            system("pause");
            system("cls");
            goto BalikDiri;
        }else{
            cout<<"Invalid input. Please enter positive values!!!!!";
            system("pause");
            system("cls");
            goto forInvalidInput;
        }
        
    }else if(select==3){
        diri2:
        cout<<"\n***MULTIPLICATION***"<<endl;
        cout<<"Input two positive values:"<<endl;
        cin>>a>>b;
        
        if(a>=0 && b>=0){
            prod=a*b;
            cout<<"The product is "<< prod<<endl;
            system("pause");
            system("cls");
            goto BalikDiri;
            
        }else{
            cout<<"Invalid input. Please enter positive values!!!!!";
            system("pause");
            system("cls");
            goto diri2;
        }  
    
    } else if(select==4){
        diri3:
        cout<<"\n***DIVISION***"<<endl;
        cout<<"Input two positive values:"<<endl;
        cin>>a>>b;
        
        if(a>=0 && b>=0){
            quo=a/b;
            cout<<"The quotient is "<< prod<<endl;
            system("pause");
            system("cls");
            goto BalikDiri;
    
        }else{
            cout<<"Invalid input. Please enter positive values!!!!!";
            system("pause");
            system("cls");
            goto diri3;
        }
    
    
    }else if(select==5){
        diri4:
        cout<<"\n***MODULUS***"<<endl;
        cout<<"Input two positive values:"<<endl;
        cin>>a>>b;
        int x=a, y=b;
        if(x>=0 && y>=0){
            mod=x%y;
            cout<<"The Modulud is "<< mod<<endl;
            system("pause");
            system("cls");
            goto BalikDiri;
        }else{
            cout<<"Invalid input. Please enter positive values!!!!!";
            system("pause");
            system("cls");
            goto diri4;
        }
    
    }else if(select==6){
        cout<<"****THANK YOU!****";
        exit(0);
        
    }else{
    cout<<"**Invalid input. Please enter values from 1-6!!!!!**"<<endl;
            system("pause");
            system("cls");
            goto BalikDiri;
    }

return 0;
}
        

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY