Saturday, June 22, 2013

Long Distance Call

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

//declare variables
double time,firstCallRate,secondCallRate,thirdCallRate,minutes,callPrice;
    int callLength;
double validRange=00.59;





//display requirement question and round input data.
cout << setprecision(2) << fixed;
cout << " Please enter the starting time of your call? " << endl;
cout << " Enter your time in this format: HH.MM, HH is hours and MM is minutes: "<<'\n'<<endl;
cin >> time;

cout<<"Please enter the length of your call:"<<endl;
cin>>callLength;
cout<<endl;

//declare condition statement.
if(time < 00.00 || time >= 24.00)

{
cout<<'\t'<<'\t'<<'\t'<<"Error !!!"<<'\n'<<endl;
cout<<'\t'<<"*************************************"<<endl;
cout << " Please enter a time between 00.00 hours and 23.59 hours." << endl;
}


minutes = time - static_cast<int>(time);

if(minutes > validRange)

{cout << " The minutes in HH.MM cannot exceed 59." << endl;}

else


//display output results.
if(time >= 00.00 && time <= 06.59)
{firstCallRate = 0.12;
    callPrice=firstCallRate*callLength;
cout << " The rate for your call will be of:$" << firstCallRate << " per minute." <<" "<<
"and your call's price will be of :$"<< callPrice<<endl;
}
else if(time >= 07.00 && time <= 19.00)
{
secondCallRate = 0.55;
callPrice=secondCallRate*callLength;
cout << " The rate for your call will be of:$" << secondCallRate << " per minute." <<" "<<
"and your call's price will be of :$"<< callPrice<<endl;
;




}
else if(time >= 19.01 && time <= 23.59)
{
thirdCallRate = 0.35;
callPrice=thirdCallRate*callLength;
cout << " The rate for your call will be of:$" << thirdCallRate << " per minute." <<" "<<
"and your call's price will be of :$"<< callPrice<<endl;
}
system("pause");
return 0;
}

No comments:

Post a Comment