Question

C++ Given a int variable named callsReceived and another int variable named operatorsOnCall, write the necessary...

C++

Given a int variable named callsReceived and another int variable named operatorsOnCall, write the necessary code to read values into callsReceived and operatorsOnCall and print out the number of calls received per operator (integer division with truncation will do). HOWEVER: if any value read in is not valid input, just print the message "INVALID". Valid input for operatorsOnCall is any value greater than 0. Valid input for callsReceived is any value greater than or equal to 0.

Revel for Starting Out with C++: From Control Structures through Objects/CHAPTER 4

0 0
Add a comment Improve this question Transcribed image text
Answer #1

- 0 x nikhil58@nikhil58-Vostro-15-3568:-/Desktop/CODE File Edit View Search Terminal Help (base) nikhil58@nikhil58-Vostro-15-

- 0 x -/Desktop/CODE/demo.cpp - Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(){
   int callsRecieved, operatorsOnCall;
   cout<< "Enter the number of calls recieved :";
   cin>>callsRecieved;
   if(callsRecieved<0)
   {
       cout<<"INVALID";
       return 0;
   }
   cout<< "Enter the number of operator on call : ";
   cin>>operatorsOnCall;
   if(operatorsOnCall<=0)
   {
       cout<<"INVALID";
       return 0;
   }
   cout<<" Calls recieved per operator are : " << callsRecieved/operatorsOnCall <<endl;
}

Add a comment
Answer #2

cin >> callsReceived;

cin >> operatorsOnCall;

if (operatorsOnCall <= 0)

  cout << "INVALID";

else if (callsReceived < 0)

  cout << "INVALID";

else

  cout << callsReceived / operatorsOnCall;


Add a comment
Know the answer?
Add Answer to:
C++ Given a int variable named callsReceived and another int variable named operatorsOnCall, write the necessary...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write in a program in C. NOTE: in mathematics, division by zero is undefined. So, in...

    Write in a program in C. NOTE: in mathematics, division by zero is undefined. So, in C, division by zero is always an error. Given a int variable  named  callsReceived and another int variable  named  operatorsOnCall write the necessary code to read values into callsReceived and operatorsOnCall and print out the number of calls received per operator (integer division with truncation will do). HOWEVER: if any value read in is not valid input, just print the message "INVALID".

  • photos arent too go so the answer there is right but im trying to figure put...

    photos arent too go so the answer there is right but im trying to figure put why codelap took operatorsoncall as > and callsrecieved aas >= if that makes any sense. why not both > or >= Workbend M Mathway Math Pr. Rate My Professors Vonida Vol Instructions Display stdout NOTE: In mathematics, division by zero is undefined. So, in C++, division by zero is always an error Given a int variable named calls Received and another int variable named...

  • C++ CodeLabs

    Not too sure what is wrong with the following code. I believe that it is something to do with the denominator being zero but not sure.NOTE: in mathematics, division by zero is undefined. So, in C++, division by zero is always an error.Given a int variable named callsReceived and another int variable named operatorsOnCall write the necessary code to read values into callsReceived and operatorsOnCalland print out the number of calls received per operator (integer division with truncation will do).code:cin...

  • Note: In mathematics, division by zero is undefined . so, in c++, division by zero is always an error given an integer v...

    Note: In mathematics, division by zero is undefined . so, in c++, division by zero is always an error given an integer variable named callsReceived and another integer variable named operatorsOnCall Write the necessary code to read values into callsReceived and operatorsOnCall and print out the number of calls received per operator (integer divison with truncation will do).

  • HELP PYTHON 3.0 (NOT JAVA) 1.HTTP is the protocol that governs communications between web servers and...

    HELP PYTHON 3.0 (NOT JAVA) 1.HTTP is the protocol that governs communications between web servers and web clients (i.e. browsers). Part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. Some of the codes and their meanings are listed below: 200, OK (fulfilled) 403, forbidden 404, not found 500, server error Given an int variable status, write a statement that prints out, on a line by...

  • JAVA Codelab (20940): [Sequential and Nested if/else Statements] Given a int variable named yesCount and another...

    JAVA Codelab (20940): [Sequential and Nested if/else Statements] Given a int variable named yesCount and another int variable named noCount and an int variable named response write the necessary code to read a value into into response and then carry out the following: if the value typed in is a 1 or a 2 then increment yesCount and print out "YES WAS RECORDED" if the value typed in is a 3 or an 4 then increment noCount and print out...

  • 3. (Dynamic Array) In C++, the largest int value is 2147483647. So. an integer larger than this cannot be stored and pr...

    3. (Dynamic Array) In C++, the largest int value is 2147483647. So. an integer larger than this cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than 2147483647, the result will be incorrect. One way to store and manipulate large integers is to store each individual digit of the number in an array. Your program must, at least, contain a function to read and store a number into an...

  • what are the answes Which yields 2.5? (double)(10/4) (int)(10) / (int)(4) 10/4 (double)(10) / (double)(4) Considering...

    what are the answes Which yields 2.5? (double)(10/4) (int)(10) / (int)(4) 10/4 (double)(10) / (double)(4) Considering integer division, determine the result of 13 / 3 4.3 05 4.0 4 Which of the following statements is a valid declaration of a constant integer variable named STEP_SIZE? int STEP_SIZE = 5; O final int STEP_SIZE = 14; double STEP_SIZE = 5; final STEP_SIZE = 10; Which is an invalid identifier? num_Cars1 3numCars O_numCars numCars Which one is not a programming language. Java...

  • JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named...

    JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named problem1. 2. Create a Java class named StringParser with the following: ApublicstaticmethodnamedfindIntegerthattakesaStringandtwocharvariables as parameters (in that order) and does not return anything. The method should find and print the integer value that is located in between the two characters. You can assume that the second char parameter will always follow the firstchar parameter. However, you cannot assume that the parameters will be different from...

  • Create a DataEntryException class whose getMessage() method returns information about invalid integer data. Write a program...

    Create a DataEntryException class whose getMessage() method returns information about invalid integer data. Write a program named GetIDAndAge that continually prompts the user for an ID number and an age until a terminal 0 is entered for both. If the ID and age are both valid, display the message ID and Age OK. Throw a DataEntryException if the ID is not in the range of valid ID numbers (0 through 999), or if the age is not in the range...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT