Final answer:
To calculate calls per operator in C++, read values into two integer variables, validate the input, and check for division by zero. If either the input is invalid or operators are zero, print "INVALID"; otherwise, perform the division and output the result.
Step-by-step explanation:
To handle the problem of dividing the number of calls received by the operators on call in C++, you will need to write code that includes input validation and conditional logic to check for division by zero. Here's an example of how you could write this code:
#include <iostream>
int main() {
int callsReceived, operatorsOnCall;
std::cin >> callsReceived >> operatorsOnCall;
if(std::cin.fail() || operatorsOnCall == 0) {
std::cout << "INVALID" << std::endl;
} else {
std::cout << (callsReceived / operatorsOnCall) << std::endl;
}
return 0;
}
This code reads the input for both callsReceived and operatorsOnCall. If the input is invalid or if operatorsOnCall is zero, it will print "INVALID". Otherwise, it will print the result of dividing callsReceived by operatorsOnCall, using integer division which truncates any decimal.