Hi i have created a program for my college assignment which asks to create a program for a telephone company that requires the program to calculate call charges for their customers, and also give discount calls depending on the time of day and day of the week.
The assignment also asks for the program to loop to give the user the option of entering data for second or third call.
So far i have done 95% of the assignment
My program asks the user to
1 input the day which call was made
2 input start time of call
3 input end time of call
Then my program outputs the
1 Number of calls made
2 Day on which the call was made
3 Call start time
4 Call end time
5 Total duration of call in minutes
6 Total discounts if any
7 Total less discounts, if any
Then my program asks the user do they want to make another call, if the user chooses yes, the program loops back to the beginning.
BUT!! This is the bit i need some advice and help,
The last part of my assignment asks me to output the totals for all calls that the user has entered into the program, any advice and help is very much welcome
below is my code
//This program will output a statement
//Created by
//Date
#include <iostream>
using namespace std;
char day, chday, pound=156, awnser ;
int call_start, call_end, call_dur, counter, bad_time, total_calls;
float time_limit, call_cap, dis_zero, dis_six, dis_three, dis_four, fullcost, discount, end_total, next_call, call_start_hrs, call_start_min,call_end_hrs,call_end_min, tot_call_start_min, tot_call_end_min, duration;
bool dur,ans, another;
float choose_day()
{
day=false;
cout<<"\n\n";
cout<<"=============================================================";
cout<<"\n\n";
cout<< "****** Enter Day of Call ******";
cout<<"\n\n";
cout<<"\n\n";
cout<<"Please enter day...Exxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
cout<<"\n\n";
cout<<"M = Monday";
cout<<"\n\n";
cout<<"U = Tuesday";
cout<<"\n\n";
cout<<"W = Wensday";
cout<<"\n\n";
cout<<"T = Thursday";
cout<<"\n\n";
cout<<"F = Friday";
cout<<"\n\n";
cout<<"A = Saturday";
cout<<"\n\n";
cout<<"S = Sunday";
cout<<"\n\n";
cout<<"\n\n";
while (!day){
//This proceedure validateds the inputed day is correct
cin>>chday;
cout<<"\n\n";
if((chday=='M')||(chday=='U')||(chday=='W')||(chday=='T')||(chday=='F')||(chday=='A')||(chday=='S'))
{
day=true;
}
else
{
day=false;
cout<<"\n\n";
cout<<"!!Error!!...Please Enter A Valid Character";
cout<<"\n\n";
}
}
return 0;
}
float input_times()
{
do{
cout<<"\n\n";
cout<<"=============================================================";
cout<<"\n\n";
cout<<" ****** Enter Call Times ******";
cout<<"\n\n";
cout<<"\n\n";
cout<<"Please Enter Start Time Of Your Call ";
cin>>call_start;
cout<<"\n\n";
cout<<"\n\n";
cout<<"Please Enter End Time Of Your Call ";
cin>>call_end;
cout<<"\n\n";
cout<<"=============================================================";
cout<<"\n\n";
time_limit=(( call_end)-(call_start));
if ((call_start<=0 )||( call_end>=2401)||(call_start>=call_end)||(time_limit>=601))
{
dur=false;
cout<<"Invalid Input! Please check your call times and re-enter";
}
else
{
dur=true;
}
}
while (!dur);
return 0;
}
float calc_min()
{
//This proceedure converts the enterd start and stop times into minuts
call_start_hrs=(call_start/100);
call_start_min=(call_start%100);
tot_call_start_min=((call_start_hrs*60)+call_start_min);
call_end_hrs=(call_end/100);
call_end_min=(call_end%100);
tot_call_end_min=((call_end_hrs*60)+call_end_min);
duration=((tot_call_end_min)-tot_call_start_min);
return 0;
}
float charge_rate()
{
if (duration<=3)
{
fullcost=(1.50);
}
else
{
fullcost=((0.30)*(duration));
}
return 0;
}
//float limit_dur()
//
//{
//
// if (duration<=600)
//
// {
// dur=true;
// }
//
// else
//
// {
// dur=false;
// }
//while (!dur);
//
//return 0;
//}
float output_day()
{
switch(chday)
//This swich satement prints out on the screen the day the call was made on
{
case 'M':
cout<<" *** Your Call was made on a Monday *** ";
cout<<"\n\n";
break;
case 'U':
cout<<" *** Your Call was made on a Tuesday *** ";
cout<<"\n\n";
break;
case 'W':
cout<<" *** Your Call was made on a Wensday *** ";
cout<<"\n\n";
break;
case 'T':
cout<<" *** Your Call was made on a Thursday *** ";
cout<<"\n\n";
break;
case 'F':
cout<<" *** Your Call was made on a Friday *** ";
cout<<"\n\n";
break;
case 'A':
cout<<" *** Your Call was made on a Saturday *** ";
cout<<"\n\n";
break;
case 'S':
cout<<" *** Your Call was made on a Sunday *** ";
cout<<"\n\n";
break;
default: cout<<"Error";
}
return 0;
}
float output_data()
{
cout<<" *** The Total number of Calls you have made today is [" <<counter++ << "]. *** ";
cout<<"\n\n";
cout<<" *** Your Call Started At " <<call_start <<" Hundred hours. *** ";
cout<<"\n\n";
cout<<" *** Your Call Ended At " <<call_end <<" Hundred hours. *** ";
cout<<"\n\n";
cout<<" *** The Total Duration Of Your Call Is "<<duration <<" Minutes. *** ";
cout<<"\n\n";
cout<<" *** The Total Cost Of Your Telephone Call Is " <<pound << fullcost<<" ***" ;
cout<<"\n\n";
return 0;
}
float calc_discounts()
{
if (chday==('S')||(chday==('A')))
{ //working
discount=fullcost*0.06;
cout<<"\n\n";
cout<<" *** The total discount is "<<pound <<discount << " at 60% ***" ;
cout<<"\n\n";
}
else
if ((call_start>=800)&& (call_end <=1700))
{//working
discount=fullcost*0.00;
cout<<"\n\n";
cout<<" *** This call has not been discounted ***" ;
cout<<"\n\n";
}
else
if ((call_start>=1700)&&(call_end<=2300))
{//working
discount=fullcost*0.03;
cout<<"\n\n";
cout<<" *** The total discount is "<<pound <<discount << " at 30% ***" ;
cout<<"\n\n";
}
else
//working
{ discount=fullcost*0.04;
cout<<"\n\n";
cout<<" *** The total discount is "<<pound <<discount << " at 40% ***" ;
cout<<"\n\n";
}
end_total=(fullcost - discount);
cout<<" *** The amount you pay, less discount is " <<pound <<end_total <<" ***" ;
cout<<"\n\n";
cout<<"============================================================";
cout<<"\n\n";
return 0;
}
float another_call()
{
do
{
cout<<"Do you want to make another Call?";
cout<<"\n\n";
cout<< "Type ( Y ) for Yes or ( N ) for No...... ";
cin>>awnser;
cout<<"\n\n";
cout<<"============================================================";
cout<<"\n\n";
if (awnser=='Y')
{
another=true;
ans=true;
}
else
{
cout<<"\n\n";
cout<<"\n\n";
cout<<" Thank you for using the Telephone Call Calculator,,,,,Goodbye";
ans=false;
cout<<"\n\n";
break;
}
}
while(!ans);
return 0;
}
int main()
{
counter=1;
do
{
choose_day();
input_times();
calc_min();
charge_rate();
output_day();
output_data();
calc_discounts();
another_call();
}
while(awnser=='Y');
system("pause");
return 0;
}