Respuesta :
Here you go,
callsReceived = stdin.nextInt();
operatorsOnCall = stdin.nextInt();
if (operatorsOnCall == 0)
System.out.println("INVALID");
else
System.out.println(callsReceived/operatorsOnCall);
Answer:
The following solution presume availability of a variable, stdin, that references a scanner object associated with standard input.
- int operatorsoncall;
- int callsreceived;
- System.out.print("Enter call received: ");
- callsreceived = stdin.nextInt();
- System.out.print("Enter number of operators on call: ");
- operatorsoncall = stdin.nextInt();
- if(operatorsoncall ==0){
- System.out.println("Invalid");
- }else{
- System.out.println("Number of call received per operator: " + callsreceived/operatorsoncall);
- }
Explanation:
Let's declare two required integer type variable, operatorsoncall ad callsreceived (Line 1 & 2).
We can use stdin object method, nextInt() to read an integer given by user and assign it to operatorsoncall ad callsreceived, respectively (Line 5 & 7).
Since the division by zero is an error, the value of operatorsoncall must not be zero. By presuming this program is only to handle division by zero error, we can set a condition if the read value held by operatorsoncall is zero, print a message "Invalid" (Line 10). Otherwise, the program will display the number of call received per operator (Line 12).