210k views
5 votes
cellPhoneBill(m,tx)Write the function cellPhoneBill()that takes two int m and txas input and returns a float.The function takes total number of minutes and text messages that user spends in a particular month and returns the bill amount. These is the policy of the carrier company:

User Matlabbit
by
5.2k points

1 Answer

3 votes

Answer:

The solution code is written in C++

  1. float cellPhone(int m, int tx){
  2. float COST_PER_MIN = 0.1;
  3. float COST_PER_MESSAGE = 0.2;
  4. float bill_amount = m * COST_PER_MIN + tx * COST_PER_MESSAGE;
  5. return bill_amount;
  6. }

Step-by-step explanation:

Firstly, declare a function named cellPhone() that takes two input parameters, m and tx (Line 1).

Since the policy of the carrier company is not given in the question, I make a presumption that the cost per minutes is $0.10 and the cost per message is $0.20 (Line 2- 3).

Next, apply the formula m * COST_PER_MIN + tx * COST_PER_MESSAGE to calculate the total bill (Line 5) and return the bill_amount as function output (Line 7).

User JackyJohnson
by
5.9k points