Question-   write a program that calculates and prints the bill for a cellular telephone company

Solution-

Question: When outputting the number of minutes the telephone service was used, output the day time and night time minutes used for a Premium type of service.
Be sure to format your output appropriately (e.g. use dollar signs and round cents to 2 decimal places).
TIP: Utilize a switch to implement your solution.
Write a program that calculates and prints the bill for a cellular telephone company. The company offers two types of service: regular and premium. Its rates vary, depending on the type of service. The rates are computed as follows:

Regular service: $10.00 plus first 50 minutes are free. Charges for over 50 minutes are $0.20 per minute.

Premium service: $25.00 plus:
a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free; charges for more than 75 minutes are $0.10 per minute.
b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are free; charges more than 100 minutes are $0.05 per minute.

Complete solution below:



#include <stdio.h>

#include <iostream>

#include <stdlib.h>

#include <cstdlib>

using namespace std;

//Money clss are here:

class Moneycls

{             

private:

            //variable for dollars

int dollar;

 //variable for cents

int cent;

public:

Moneycls(int dol, int cen)

{

dollar = dol; cent = cen;

}

 

void AddDollar(int _dollar) {dollar += _dollar;}

void AddCents(int _cent)

{

cent += _cent;

 

while(cent > 99)

{

cent -= 100; ++dollar;

}

}

void DisplayMoney()

{

cout<<"--> $"<<dollar<<"."<<cent;

}

};

 

//Here is main function:

int main()

{

Moneycls mone(0, 0);

int service;

cout<<"* what is Service do you use? "<<endl;

cout<<"1-->Choise for Regular service "<<endl;

 

cout<<"2-->Choise for Premium service "<<endl;

cin>>service;

switch(service)

{

case 1:

{

int minutes = 0;

mone.AddDollar(10);

cout<<"Hello \n Enter the number of minutes: ";

cin>>minutes;

if (minutes > 50)

{

minutes -= 50;

mone.AddCents(minutes*20);

}

cout<<"* \n Bill Payment Services is := ";

mone.DisplayMoney();

cout<<endl;

} break;

case 2:

{

int minutes1;

int minutes2;

mone.AddDollar(25);

cout<<" Enter the Number of Minutes (use from 6:00 a.m. to 6:00 p.m):= ";

cin>>minutes1;

cout<<" Enter the Number of Minutes (use from 6:00 p.m. to 6:00 a.m):= ";

cin>>minutes2;

if (minutes1 > 75)

{

minutes1 -= 75;

mone.AddCents(minutes1 * 10);

}

if (minutes2 > 100)

{

minutes2 -= 100;

mone.AddCents(minutes2 * 5);

}

cout<<"Bill Payment Services is := ";

mone.DisplayMoney();

cout<<endl;

}; break;

default: cout<<"Error. \n Wrong input!!! \n Please Enter correct value."<<endl;

}

system("pause");

return 0;

}

Our happy customers

They are fast in responding to homework questions. they have the best technical writers. Thanks for helping me with my programming doubts.

studentDyana
5  stars image

I contact to disklib for homework, they help me out, despite there was some technical issue they gone through extra mile for me and provide me good quality work in first priority. 100% recommended.

studying on laptopAsif Waheed
5  stars image

Desklib's study resources are best & unique. Their study database is easy to access and easy to use.
100 % recommended.

library and studentsMike Taylor
5  stars image