C++ Program : Call Cost



Write a program that computes the cost of a long-distance call. The cost of the call is determines according to the following rate schedule:

a.      Any call between 8:00 Am and 6:00 PM, Monday through Friday is billed at a rate of $0.4 per minute.

b.      Any call starting before 8:00 AM or after 6:00PM, Monday through Friday, is charged at a rate of $0.25 per minute.

c.       Any call started on a Saturday or Sunday is charged at a rate of $0.15 per minute.

The Input will consist of the day of the week, the time the call started, and the length of the call in minutes. The output will be the cost of the call. The time is to be input in 24-hours notation.

#include<iostream>

int main()

{

                    int st, m;

                    double a;

                    char f, s, c;

                    do

                    {

                        cout<<"This is a Program that Calculates the cost of a long Distance Call.\n";

           cout<<" Please provide the necessary details. \n";

                        cout<<"  A.  Enter the Time (in 24 hour format) you have started the call : ";

           cin>>st;

                        cout<<"  B.  Enter the duration of the call(in minutes) : ";

                        cin>>m;

                        cout<<"  C.  Enter the first two letters of the day of the call : ";

           cin>>f>>s;


                        if (((f=='M')||(f=='m'))&&((s=='O')||(s=='o')))

                        {

                            if ((st>=8)&&(st<=18))

                                a=m*0.40;

                            else

                                a=m*0.25;

                        }

                        else if (((f=='T')||(f=='t'))&&((s=='U')||(s=='u')))

                        {

                            if ((st>=8)||(st<=18))

                                a=m*0.40;

                else

                                a=m*0.25;

                        }

                        else if (((f=='W')||(f=='w'))&&((s=='E')||(s=='e')))

                        {

                            if ((st>=8)||(st<=18))

                                a=m*0.40;

                            else

                                a=m*0.25;

                        }

                        else if (((f=='T')||(f=='t'))&&((s=='H')||(s=='h')))

                        {

                            if ((st>=8)||(st<=18))

                                a=m*0.40;

                            else

                                a=m*0.25;

           }

                        else if (((f=='F')||(f=='f'))&&((s=='R')||(s=='r')))

                        {

                            if ((st>=8)||(st<=18))

                                a=m*0.40;

                            else

                                a=m*0.25;

                        }

                        else if (((f=='S')||(f=='s'))&&((s=='A')||(s=='a')))

                            a=m*0.15;

                        else if (((f=='S')||(f=='s'))&&((s=='U')||(s=='u')))

                            a=m*0.15;


           cout.setf(ios::fixed);

           cout.setf(ios::showpoint);

           cout.precision(2);

                        cout<<"Your long distance call costs $"<<a<<".\n";

                        cout<<"Do you want to calculate another long distance call cost? [Y/N]\n";

                        cin>>c;


                    }

                    while ((c=='Y')||(c=='y'));

       cout<<"Thank You for Using the Program!\n";

       cin.get ();

       cin.get ();

                    return 0;

                }
Share:

No comments:

Post a Comment

Thanks for Suggestion / Comment!

God Bless!

Our Sponsor

Popular Post