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.
1
Expert's answer
2014-10-31T13:11:18-0400
#include <stdlib.h> #include <iostream> #include <stdio.h> #include <cstdlib> using namespace std; class Money { private: int dollars;
int cent; public: Money(int dol, int cen) { dollars = dol; cent = cen; }
void AddDollars(int _dollars) {dollars += _dollars;} void AddCents(int _cent) { cent += _cent; while(cent > 99) { cent -= 100; ++dollars; } } void DisplayMoney() { cout<<"$"<<dollars<<"."<<cent; } }; int main() { Money money(0, 0); int service; cout<<"what service do you use?"<<endl; cout<<"1.Regular service"<<endl; cout<<"2.Premium service"<<endl; cin>>service; switch(service) { case 1: { int minutes = 0; money.AddDollars(10); cout<<"Enter the number of minutes: "; cin>>minutes; if (minutes > 50) { minutes -= 50; money.AddCents(minutes*20); } cout<<"bill payment services is "; money.DisplayMoney(); cout<<endl; } break; case 2: { int minutes1; int minutes2; money.AddDollars(25); cout<<"Enter the number of minutes (from 6:00 a.m. to 6:00 p.m): "; cin>>minutes1; cout<<"Enter the number of minutes (from 6:00 p.m. to 6:00 a.m): "; cin>>minutes2; if (minutes1 > 75) { minutes1 -= 75; money.AddCents(minutes1 * 10); } if (minutes2 > 100) { minutes2 -= 100; money.AddCents(minutes2 * 5); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment