hey..would anyone help me with my code. the program is supposed to get telephone starting and ending times from a file from the user then outputs the total duration and calculates the cost. my program does all this but it is giving me a problem in finding the total cost since am supposed to use the different call rates. it is supposed to read from files starting time and ending time. thank you. here is the attachment of the full code working(cpp1.cpp)..

am also supposed to modularize the program but it is kind of also a challenge.
i have also attached the modularized header files which are giving hard time. please let me know if there is something wrong with the header files

Attachments
#include "UserInput.h"

#include "counter.h"

#include "TimeAndDate.h" 

using namespace std;

double equality();

double call_cost();
#include "UserInput.h"

#include "TimeAndDate.h"

#define maxsecs 60

#define S 4

//using namespace std;

//const int maxsecs=60;//upperbound value

struct counter

{
	int sec_count_value;

	time_info start;

	time_info end;

};

struct sec

{

	counter seconds;

};

int minutes[S]; // Array to store the minute count values

int hours[S]; // Array to store hour count values

int days[S]; //Array to store day count values

int months[S]; //Array to store month count values

int years[S]; //Array tp store month count values

void increment(counter& seconds,time_info& start,time_info& end);

void time_increment(int& hours_count,int&minute_count, double& day_count,double& month_count,double& year_count,time_info& start, time_info& end);
#include <iostream>

#include <string>

#include <fstream>

#include <stdlib.h>

using namespace std;

const int maxsecs=60;//upperbound value

const int S=4;//Array size

struct time_info

{
	int hours,minutes;

	double day,month,year;

};

struct time_details // Structure for starting and ending times

{

	time_info start;

	time_info end;
 
};

struct counter

{
	int sec_count_value;

	time_info start;

	time_info end;

};

struct sec

{

	counter seconds;

};

time_details time_and_date[S];  //Array of the structure time_details and also uses the values of 

								//the structre time_info

int minutes[S]; // Array to store the minute count values

int hours[S]; // Array to store hour count values

int days[S]; //Array to store day count values

int months[S]; //Array to store month count values

int years[S]; //Array tp store month count values

double hour();

double minute();

double day();

double month();

double year();

void disp();

double value();

double equality();

double call_cost();

void get_integers();

void set(double& current_value);

void user_input(time_info& start, time_info& end);

void increment(counter& seconds,time_info& start, time_info& end);

void time_increment(int& hours_count,int&minute_count, double& day_count,double& month_count,double& year_count,time_info& start, time_info& end);

int main()

{

	disp();

	cout<< endl;
	
	return 0;

}

void user_input(time_info& start, time_info& end) 

{

	int i;

	ifstream in_stream1;//input file stream for starting times named in_stream1

	ifstream in_stream2; //input file stream for ending times named in_stream2

	ofstream out_stream1; //output file stream for starting times named out_stream1
		
	ofstream out_stream2; //output file stream for ending times named out_stream2

	in_stream1.open("start time.txt");

	in_stream2.open("end time.txt");

	out_stream1.open("start time output.txt");
		
	out_stream2.open("end time output.txt");

	if((in_stream1.fail())||(in_stream2.fail()))
		
	{
			
		cout << "Input file opening failed." << endl<<endl;
			
		exit(1);	
	
	}

	for (i=0; i<S;i++)
	
	{

		// the input and output files save the information in the array time_and_date 

		in_stream1	>>time_and_date[i].start.hours >>time_and_date[i].start.minutes>>time_and_date[i].start.day
				
					>>time_and_date[i].start.month>>time_and_date[i].start.year;

		in_stream2	>>time_and_date[i].end.hours >>time_and_date[i].end.minutes>>time_and_date[i].end.day
				
					>>time_and_date[i].end.month>>time_and_date[i].end.year;

		out_stream1 <<time_and_date[i].start.hours <<" "<<time_and_date[i].start.minutes<<" "<<time_and_date[i].start.day<<" "
		
					<<time_and_date[i].start.day<<" "<<time_and_date[i].start.month<<" "<<time_and_date[i].start.year<<endl;

		out_stream2 <<time_and_date[i].end.hours <<" "<<time_and_date[i].end.minutes<<" "<<time_and_date[i].end.day<<" "
		
					<<time_and_date[i].end.day<<" "<<time_and_date[i].end.month<<" "<<time_and_date[i].end.year<<endl;


	}

	in_stream1.close();

	in_stream2.close();

	out_stream1.close();

	out_stream2.close();

}

void get_integers()

{

	time_info start,end;
	
	user_input(start,end);
	
	start.hours = start.hours;

	start.minutes = start.minutes;

	start.day = start.day;

	start.month = start.month;

	start.year = start.year;

}

void set (double& current_value)

{

	time_info start,end;

	counter seconds;
	
	increment(seconds,start,end);
	
	current_value = seconds.sec_count_value;
		
}

double value()

{
	
	double current_value;

	set(current_value);

	return current_value;

}

double equality()

{

	int i;

	time_info start, end;

	user_input(start,end);

	for(i=0;i<S;i++)

	{
	
		if (((time_and_date[i].start.hours==time_and_date[i].end.hours) && (time_and_date[i].start.minutes==time_and_date[i].end.minutes)) 
		
		&& ((time_and_date[i].start.day==time_and_date[i].end.day) && (time_and_date[i].start.month==time_and_date[i].end.month) 
		
		&& (time_and_date[i].start.year==time_and_date[i].end.year)))

		{

			cout<<"Your time is the same"<<endl<<endl;
	
			return 1;	

		}

	}

	return 0;

}

void increment (counter& seconds,time_info& start, time_info& end)

{
	
	double i;
	
	user_input(start,end);

	int sec_count;

	sec_count=0;

	for(i=0;i<maxsecs;i++) 
	
	{	
		
		sec_count++;
		
	}

	seconds.sec_count_value=sec_count;
	
}

void time_increment(int& hours_count,int&minute_count, double& day_count,double& month_count,double& year_count,time_info& start, time_info& end) 

{

	int sec_count,i,a;
	
	counter seconds;
	
	increment(seconds,start,end);
	
	hours_count=0;
	
	minute_count=0;
	
	day_count=0;
	
	month_count=0;
	
	year_count=0;
	
	int temp_start;
	
	int temp_end;
	
	if (!equality())

	{

		if (sec_count = 60)
		
		{
			
			for(i=0;i<S;i++)
		
			{
				
				temp_start=time_and_date[i].start.minutes;
				
				temp_end=time_and_date[i].end.minutes;
			
				for(a=temp_start;a<temp_end;a++)
				
				{
				
					minute_count++;

					minutes[i]=minute_count; // the values for minute_count are assigned to the array minutes		

				}

				minute_count=0;

				temp_start=time_and_date[i].start.hours;
				
				temp_end=time_and_date[i].end.hours;
			
				for(a=temp_start;a<temp_end;a++)
			
				{
				
					hours_count++;

					hours[i]=hours_count; // the values for hour_count are assigned to the array hours
				
				}


				hours_count=0;
			
				temp_start=time_and_date[i].start.day;
				
				temp_end=time_and_date[i].end.day;
			
				for(a=temp_start;a<temp_end;a++)
				
				{
				
					day_count++;

					days[i]=day_count++; // the values for day_count are assigned to the array days
				
				}
			
				day_count=0;

				temp_start=time_and_date[i].start.month;
				
				temp_end=time_and_date[i].end.month;
			
				for(a=temp_start;a<temp_end;a++)
				
				{
				
					month_count++;

					months[i]=month_count++; // the values for month_count are assigned to the array days
				
				}

				month_count=0;
			
				temp_start=time_and_date[i].start.year;
				
				temp_end=time_and_date[i].end.year;
			
				for(a=temp_start;a<temp_end;a++)
				
				{
				
					year_count++;

					years[i]=year_count++;// the values for the year count are assigned to the array years
				
				}

				year_count=0;
			
			}

		}

	}
	
}

double call_cost()

{

	double temp_rate,count_rate,rate,rate_one,rate_two,rate_three;

	double day_count,month_count,year_count;

	double temp_value,temp_value2;

	int hours_count,minute_count,hour_rate,i;

	time_info start,end;

	counter seconds;

	rate=0;
	
	count_rate=0;

	hour_rate=0;

	//int rates[S]={0};

	time_increment(hours_count,minute_count,day_count,month_count,year_count,start,end);

	increment(seconds,start,end);
	
	for (i=0;i<S;i++)

	{

		if ((time_and_date[i].start.hours<7) && (time_and_date[i].end.hours<=7))

		{		
		
			//rate =((minute_count)+(hours_count*60))*0.10;

		//	for(i=0;i<)
			
			rate_one =((minutes[i])+(hours[i]*60))*0.10;

			//cout<<"the cost is:" <<rate<<endl<<endl;


		}

		if ((time_and_date[i].start.hours<=7)&&(time_and_date[i].end.hours>7)&&(time_and_date[i].end.hours<=16))

		{
	
			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=8;i<temp_value2;i++)
			
			{

				count_rate++;

			}

			for(i=temp_value;i<7;i++)
			
			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.15;

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.10;

			rate_one=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;


		}

		if ((time_and_date[i].start.hours>7)&&(time_and_date[i].start.hours<=16) && (time_and_date[i].end.hours<=16))

		{
			//cout<<"even if";

			rate_two =((minutes[i])+(hours[i]*60))*0.15;

			//cout<<"the cost is:" <<rate<<endl<<endl;

		}

		if((time_and_date[i].start.hours<=16)&&(time_and_date[i].end.hours>16)&&(time_and_date[i].end.hours<23))
	
		{

			//cout<<"even if";
			
			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=16;i<temp_value2;i++)

			{

				count_rate++;

			}

			for(i=temp_value;i<16;i++)

			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.12; // ith number of postion for minutes

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;

			rate_two=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;

			//return rate;

		}

		if ((time_and_date[i].start.hours>16)&&(time_and_date[i].start.hours<=23) && (time_and_date[i].end.hours<=23))

		{

			rate_three =((minutes[i])+(hours[i]*60))*0.12;

			//cout<<"the cost is:" <<rate<<endl<<endl;

			//return rate;

		}

		if((time_and_date[i].start.hours<=23)&&(time_and_date[i].end.hours>23)&&(time_and_date[i].end.hours<7))
	
		{

			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=23;i<temp_value2;i++)

			{

				count_rate++;

			}

			for(i=temp_value;i<23;i++)

			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.10;

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;

			rate_three=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;

		//	return rate;

		}


	}

	rate=rate_one+rate_two+rate_three;

	return rate;	

}
		
double hour()

{
	double day_count,month_count,year_count;

	int hours_count,minute_count;

	time_info start,end;
	
	time_increment(hours_count,minute_count,day_count,month_count,year_count,start,end);

	return s
05 30 01 02 2007
15 28 01 02 2007
19 10 01 02 2007
15 27 01 02 2007
#include <iostream>

#include <stdlib.h>

#include <string>

#include <fstream>

#include "userinput.h"

#include "counter.h"

#include "TimeAndDate.h"

#include "CallCost.h"

using namespace std;

void disp();

//void main();

void main()

{

	disp();

	cout<< endl;
	
//	return 0;

}

void disp() //3

{

	int hours_count,minute_count,i;
	
	double day_count,month_count,year_count;

	double rate;

	//time_info start, end;

	time_increment(hours_count,minute_count,day_count,month_count,year_count,start,end);

	int n=0;

	for (i=0;i<S;i++)

	//rate;
		
	//call_cost();
	
	{
		
		n++;

		cout<< "Your call " <<n<<" started at " <<time_and_date[i].start.hours<<":"<<time_and_date[i].start.minutes<<"/"
		
			<<time_and_date[i].start.day<<"/"<<time_and_date[i].start.month<<"/" << time_and_date[i].start.year;
	
		cout<< " and ended at "<<time_and_date[i].end.hours<<":"<<time_and_date[i].end.minutes<<"/"
		
			<<time_and_date[i].end.day<<"/"<<time_and_date[i].end.month<<"/" << time_and_date[i].end.year<<endl<<endl;
		
		cout<< "The duration is " << hours[i] << " Hour(s) and " <<minutes[i] <<" Minutes"<<endl<<endl;

		hours_count=hours[i]+hours_count;

		minute_count=minutes[i]+minute_count;

		rate=call_cost();

	//	cout<< "The cost is RM: "<<rate <<endl<<endl;

	}

	cout<< "The total duration is " << hours_count << " Hour(s) and " <<minute_count <<" Minutes"<<endl<<endl;

	cout<< "The total cost is RM"<<rate<<endl;

}
03 10 01 02 2007
12 22 01 02 2007
17 00 01 02 2007
14 12 01 02 2007
#include "UserInput.h"

#include "counter.h"

using namespace std;

double hour();

double minute();

double day();

double month();

double year();
#include <iostream>

#include <string>

#include <fstream>

#define S 4

//#include "counter.h"

//using namespace std;

struct time_info

{
	int hours,minutes;

	double day,month,year;

};

struct time_details // Structure for starting and ending times

{

	time_info start;

	time_info end;
 
};

void user_input(time_info& start, time_info& end);

void get_integers();

void set(double& current_value);

double value();

Wow. We give out about people not giving us enough code all the time ... but all the code... one would think it's a good thing...
However, I, for one, am not going to look at any of them. I think it's generally said to post the smallest segment of code which illustrates the problem. Please do so. You'll get more responses in my opinion.

Comments
I would agree with that

Rather posts the portion of the code which is giving you trouble, and also detail the problem that you are facing.

Wow. We give out about people not giving us enough code all the time ... but all the code... one would think it's a good thing...
However, I, for one, am not going to look at any of them. I think it's generally said to post the smallest segment of code which illustrates the problem. Please do so. You'll get more responses in my opinion.

am actually new at this so didnt actualy know wat to post..here is the segment that is supposed to calculate the call cost but it only uses the first rate of 0.10..hope this is more useful

Attachments
double call_cost()

{

	double temp_rate,count_rate,rate,rate_one,rate_two,rate_three;

	double day_count,month_count,year_count;

	double temp_value,temp_value2;

	int hours_count,minute_count,hour_rate,i;

	time_info start,end;

	counter seconds;

	rate=0;
	
	count_rate=0;

	hour_rate=0;

	//int rates[S]={0};

	time_increment(hours_count,minute_count,day_count,month_count,year_count,start,end);

	increment(seconds,start,end);
	
	for (i=0;i<S;i++)

	{

		if ((time_and_date[i].start.hours<7) && (time_and_date[i].end.hours<=7))

		{		
		
			//rate =((minute_count)+(hours_count*60))*0.10;

		//	for(i=0;i<)
			
			rate_one =((minutes[i])+(hours[i]*60))*0.10;

			//cout<<"the cost is:" <<rate<<endl<<endl;


		}

		if ((time_and_date[i].start.hours<=7)&&(time_and_date[i].end.hours>7)&&(time_and_date[i].end.hours<=16))

		{
	
			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=8;i<temp_value2;i++)
			
			{

				count_rate++;

			}

			for(i=temp_value;i<7;i++)
			
			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.15;

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.10;

			rate_one=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;


		}

		if ((time_and_date[i].start.hours>7)&&(time_and_date[i].start.hours<=16) && (time_and_date[i].end.hours<=16))

		{
			//cout<<"even if";

			rate_two =((minutes[i])+(hours[i]*60))*0.15;

			//cout<<"the cost is:" <<rate<<endl<<endl;

		}

		if((time_and_date[i].start.hours<=16)&&(time_and_date[i].end.hours>16)&&(time_and_date[i].end.hours<23))
	
		{

			//cout<<"even if";
			
			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=16;i<temp_value2;i++)

			{

				count_rate++;

			}

			for(i=temp_value;i<16;i++)

			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.12; // ith number of postion for minutes

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;

			rate_two=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;

			//return rate;

		}

		if ((time_and_date[i].start.hours>16)&&(time_and_date[i].start.hours<=23) && (time_and_date[i].end.hours<=23))

		{

			rate_three =((minutes[i])+(hours[i]*60))*0.12;

			//cout<<"the cost is:" <<rate<<endl<<endl;

			//return rate;

		}

		if((time_and_date[i].start.hours<=23)&&(time_and_date[i].end.hours>23)&&(time_and_date[i].end.hours<7))
	
		{

			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=23;i<temp_value2;i++)

			{

				count_rate++;

			}

			for(i=temp_value;i<23;i++)

			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.10;

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;

			rate_three=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;

		//	return rate;

		}


	}

	rate=rate_one+rate_two+rate_three;

	return rate;	

}

Rather posts the portion of the code which is giving you trouble, and also detail the problem that you are facing.

i am facing two problems.. am supposed to calculate the call cost but the programe only uses the first rate of 0.10..am also supposed to modularize the whole program but i get a warning that says recussion problem.i attached the header files so that someone could tel me if there is somethung wrong. thank you

Attachments
double call_cost()

{

	double temp_rate,count_rate,rate,rate_one,rate_two,rate_three;

	double day_count,month_count,year_count;

	double temp_value,temp_value2;

	int hours_count,minute_count,hour_rate,i;

	time_info start,end;

	counter seconds;

	rate=0;
	
	count_rate=0;

	hour_rate=0;

	//int rates[S]={0};

	time_increment(hours_count,minute_count,day_count,month_count,year_count,start,end);

	increment(seconds,start,end);
	
	for (i=0;i<S;i++)

	{

		if ((time_and_date[i].start.hours<7) && (time_and_date[i].end.hours<=7))

		{		
		
			//rate =((minute_count)+(hours_count*60))*0.10;

		//	for(i=0;i<)
			
			rate_one =((minutes[i])+(hours[i]*60))*0.10;

			//cout<<"the cost is:" <<rate<<endl<<endl;


		}

		if ((time_and_date[i].start.hours<=7)&&(time_and_date[i].end.hours>7)&&(time_and_date[i].end.hours<=16))

		{
	
			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=8;i<temp_value2;i++)
			
			{

				count_rate++;

			}

			for(i=temp_value;i<7;i++)
			
			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.15;

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.10;

			rate_one=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;


		}

		if ((time_and_date[i].start.hours>7)&&(time_and_date[i].start.hours<=16) && (time_and_date[i].end.hours<=16))

		{
			//cout<<"even if";

			rate_two =((minutes[i])+(hours[i]*60))*0.15;

			//cout<<"the cost is:" <<rate<<endl<<endl;

		}

		if((time_and_date[i].start.hours<=16)&&(time_and_date[i].end.hours>16)&&(time_and_date[i].end.hours<23))
	
		{

			//cout<<"even if";
			
			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=16;i<temp_value2;i++)

			{

				count_rate++;

			}

			for(i=temp_value;i<16;i++)

			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.12; // ith number of postion for minutes

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;

			rate_two=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;

			//return rate;

		}

		if ((time_and_date[i].start.hours>16)&&(time_and_date[i].start.hours<=23) && (time_and_date[i].end.hours<=23))

		{

			rate_three =((minutes[i])+(hours[i]*60))*0.12;

			//cout<<"the cost is:" <<rate<<endl<<endl;

			//return rate;

		}

		if((time_and_date[i].start.hours<=23)&&(time_and_date[i].end.hours>23)&&(time_and_date[i].end.hours<7))
	
		{

			temp_value=time_and_date[i].start.hours;//Temporary values used to loop through the array values
				
			temp_value2=time_and_date[i].end.hours;

			for(i=23;i<temp_value2;i++)

			{

				count_rate++;

			}

			for(i=temp_value;i<23;i++)

			{

				hour_rate++;

			}

			temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.10;

			rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;

			rate_three=(rate+temp_rate);

			//cout<<"the cost is:" <<rate<<endl<<endl;

		//	return rate;

		}


	}

	rate=rate_one+rate_two+rate_three;

	return rate;	

}
This question has already been answered. Start a new discussion instead.