Hi I am creating an program for my degree, it’s a program that logs call times, days, gives total cost and discounts depending on days of the week, at the end of the program it out puts all results then give an option to start over again or exit.
So far I have managed to do this, but if I take the option to start over again and make another call, at the end of the program, the options to start over again or exit don work the way they should,
Also u will see that I have a cout statement showing how many calls have been made, at the moment I am not sure how to make the number change according to how many times the program has looped?
Any help will be much appreciated ,

Below is the exact code i have
Thanks
Steve

//This program will output a statement
//Created by Stephen Newhall
//Date 17/11/2010

#include <cstdio>
#include <iomanip>30
#include <iostream>

using namespace std;
char day, chday, awnser;
int call_start, duration, call_end, call_start_hrs, call_start_min, tot_call_start_min, call_end_hrs, call_end_min, tot_call_end_min, total_calls;
float fullcost, discount, call_duration, end_total, next_call;
bool ans, another;


float input_data()

//This proceedure provides input options for days of the week
{


    day=false;

    cout<<"Please enter day...E.gqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
    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<<"!!Error!!...Please Enter A Valid Character";
                cout<<"\n\n";
            }

    }




    return (0);

}


int input_times()

{

//This proceedure provides input options for satart and end times of calls  
cout<<"\n\n";

cout<<"=============================================================";    
cout<<"\n\n";

cout<<"       ***** Times Of Calls *****";
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";



return 0;
}



int total_call_time()

{
//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()

{
    //This proceedure tells the program when to. and what to charge the caller per minut

cout<<"       ***** Call Charges *****";
    cout<<"\n\n";

    double fullcost = 1.50;

    if(duration<=3)
    {
        fullcost=((1.50)*(duration));
    }
    else
    {
        fullcost=((0.30)*(duration));
    }




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";

        }


//This proceedure prints out , call satrt, call end, total duration, total cost and total cost less discount

total_calls=1;

cout<<"The Total number of Calls made today is -" <<total_calls <<"-";
    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.setf(ios::fixed); 
cout<< setw(2) << setprecision(2)<<"The Total Cost Of Your Telephone Call Is " << fullcost <<" Pounds.";
cout<<"\n\n";
{

    //This proceedure calculates the discount depending on the day of week and prints to screen

        if ((chday=='M')||(chday=='U')||(chday=='W')||(chday=='T')||(chday=='F'))
        {
        discount=(fullcost * 0.04);

cout<<"The Total Discount Of Your Telephone Call is " << discount <<" Pounds at 40%.";
cout<<"\n\n";
        }

    else if ((chday=='A')||(chday=='S'))
        {
        discount=(fullcost * 0.06);

cout<<"The Total discount Of Your Telephone Call is " << discount <<" Pounds at 60%.";
cout<<"\n\n";

        }


    }

end_total=(fullcost - discount);

cout<<"\n\n";
cout<<"   ***  The amount you pay, less discount is " <<end_total <<" Pounds.  ***";
cout<<"\n\n";
cout<<"============================================================"; 
    cout<<"\n\n";


return 0;
}


void uesr_reply()
{

    do

    {
cout<<"Do you want to make another Call?";
cout<<"\n\n";
cout<< "Type ( Y ) for Yes or ( N ) for No ";
cout<<"\n\n"; 
cin>>awnser;
            if (awnser=='Y')

            {
            another=true;
            ans=true;
            }
        else
            {
            cout<<" Thank you for using the Telephone Call Calculator,,,,,Goodbye";
            ans=false;      
            cout<<"\n\n";
            break;
            }


    }

    while(!ans);


}


int main()

{
do
{

input_data();
input_times();
total_call_time();
charge_rate();
uesr_reply();
}
while(another);

system("pause");

return 0;
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Please enclose your code in code-tag so it's easier to read. But have you tried;

int counter=1;
while{
cout>>counter++;

}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

sorry

//This program will output a statement
//Created by Stephen Newhall
//Date 17/11/2010

#include <cstdio>
#include <iomanip>30
#include <iostream>

using namespace std;
char day, chday, awnser;
int  call_dur, call_start, duration, call_end, call_start_hrs, call_start_min, tot_call_start_min, call_end_hrs, call_end_min, tot_call_end_min, total_calls;
float fullcost, discount, call_duration, end_total, next_call;
bool ans, another;


float input_data()

//This proceedure provides input options for days of the week
{


	day=false;

	cout<<"Please enter day...E.gqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
	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<<"!!Error!!...Please Enter A Valid Character";
				cout<<"\n\n";
			}

	}
 



	return 0;
	
}
	

int input_times()

{
call_dur=false;
//This proceedure provides input options for satart and end times of calls	
cout<<"\n\n";

cout<<"=============================================================";	
cout<<"\n\n";

cout<<"		***** Times Of Calls *****";
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";

	//while (!call_dur)
	
		
		
		if  (call_start < call_end)

			{
			call_dur==true;
			cout<<"\n\n";
			
			}
			else
			{
				 call_dur==false;
				cout<<"!!Error!!...Please Enter A Valid Time ";
				cout<<"\n\n"<<endl;
			
			}

	
return 0;
}


	






int total_call_time()

{
//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()

{
	//This proceedure tells the program when to. and what to charge the caller per minut

cout<<"		***** Call Charges *****";
	cout<<"\n\n";

	double fullcost = 1.50;
	
	if(duration<=3)
	{
		fullcost=((1.50)*(duration));
	}
	else
	{
		fullcost=((0.30)*(duration));
	}



		 
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";
			
		}
	

//This proceedure prints out , call satrt, call end, total duration, total cost and total cost less discount
	
total_calls=1;

cout<<"The Total number of Calls made today is -" <<total_calls <<"-";
	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.setf(ios::fixed); 
cout<< setw(2) << setprecision(2)<<"The Total Cost Of Your Telephone Call Is " << fullcost <<" Pounds.";
cout<<"\n\n";
{

	//This proceedure calculates the discount depending on the day of week and prints to screen
	
		if ((chday=='M')||(chday=='U')||(chday=='W')||(chday=='T')||(chday=='F'))
		{
		discount=(fullcost * 0.04);
		
cout<<"The Total Discount Of Your Telephone Call is " << discount <<" Pounds at 40%.";
cout<<"\n\n";
		}

	else if ((chday=='A')||(chday=='S'))
		{
		discount=(fullcost * 0.06);
		
cout<<"The Total discount Of Your Telephone Call is " << discount <<" Pounds at 60%.";
cout<<"\n\n";
		
		}
	

	}

end_total=(fullcost - discount);

cout<<"\n\n";
cout<<"	***  The amount you pay, less discount is " <<end_total <<" Pounds.  ***";
cout<<"\n\n";
cout<<"============================================================";	
	cout<<"\n\n";


return 0;
}


void uesr_reply()
{
		
	do

	{
cout<<"Do you want to make another Call?";
cout<<"\n\n";
cout<< "Type ( Y ) for Yes or ( N ) for No ";
cout<<"\n\n";	
cin>>awnser;
			if (awnser=='Y')
			
			{
			another=true;
			ans=true;
			}
		else
			{
			cout<<" Thank you for using the Telephone Call Calculator,,,,,Goodbye";
			ans=false;		
			cout<<"\n\n";
			break;
			}

	
	}

	while(!ans);


}


int main()

{
do
{

input_data();
input_times();
//val_call_times();
total_call_time();
charge_rate();
uesr_reply();
}
while(another);

system("pause");

return 0;
}
main(){
int counter=1;
......
do{
........
cout>>counter++;
}
while(another)

}

Edited 6 Years Ago by geojia: n/a

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