#include <iostream>
#include <fstream> // I/O
#include <iomanip> // For setw()
using namespace std;

ofstream     outputfile("output.txt");     // Output file

const int MAX_FILE_NAME = 35;
const double INTEREST_RATE1 = 0.010;
const double INTEREST_RATE2 = 0.010;
const double LEVEL_ONE_BALANCE = 1000.00;
const double MINIMUM_PAYMENT = 10.00;
const double MINIMUM_PAYMENT_PERCENT = 0.10;



class Account
{
public:
Account( double Balance, double InterestRate1, double InterestRate2);
Account( );
double Payment();
double InterestDue();
double TotalAmountDue();
void output(ostream &out); // Print values on output stream out(); 

private:
double balance;
double interest;
double payment;
double interest_rate1;
double interest_rate2;
double total_amount_due;
};


void open_input(ifstream& input, char name[])
void process_file(ifstream& input);

int main ()

{ 
char again;
char file_name[MAX_FILE_NAME + 1];
ifstream input_numbers;

cout << "This program calculates values\n"
	<< "customer invoices.\n" << endl;
system("pause");

	do
	{
		system ("cls");
		open_input(input_numbers, file_name);
		process_file(input_numbers);
		input_numbers.close();

		cout << "\n Another File?" << endl;
		cin >> again;
		cin.ignore(256, '\n');	
	}
	while (again == 'y' || again == 'Y');


		cout << "\nEnd!!!!!" << endl;
		outputfile << "\nThanks for using program";
		outputfile.close();

		return 0;}

		void open_input (ifstream& input, char name[])

		{
			int count = 0;

		do
		{ count++; 
			if (count !=1)
			{ cout << "\n\aInvalid file or it does not exist." << endl;
	
		}

		cout << "\nEnter the input file name,please. (maximum of " << MAX_FILE_NAME
			<< " characters please)\n:>";
		cin.get(name, MAX_FILE_NAME + 1);
		cin.ignore(256, '\n');
		input.clear();
		input.open(name,ios_base::in);
		}
		while (input.fail() );
}

	void process_file(ifstream& input)

		{
			double value;

		Account thisAccount;
		while (input >> value)
		{
			thisAccount = Account (value, INTEREST_RATE1, INTEREST_RATE2);

			thisAccount.output(cout);
			thisAccount.output(outputfile);
		}
}

			Account::Account ( double Balance, double InterestRate1, double InterestRate2)

			{ 
				balance = Balance;
				interest_rate1 = InterestRate1;
				interest_rate2 = InterestRate2;
					Payment();
			}

			Account::Account()
			{
				balance = 0;
			}
double Account::InterestDue()
{ 
	return interest;
}

double Account::TotalAmountDue()
{
return 4;
}

double Account:: Payment( )
{

double newbalance; 

if ( balance > LEVEL_ONE_BALANCE)
     interest = (balance - LEVEL_ONE_BALANCE) * interest_rate2 + LEVEL_ONE_BALANCE * interest_rate1;
else
     interest = balance * interest_rate1;

newbalance = balance + interest;

payment = newbalance* MINIMUM_PAYMENT_PERCENT;

if ( newbalance < MINIMUM_PAYMENT)
     payment = newbalance;
else
     if ( payment < MINIMUM_PAYMENT)
          payment=MINIMUM_PAYMENT;

return payment;
}
void Account::output(ostream &out)

{  out.setf(ios::fixed);      out.setf(ios::showpoint);     out.precision(2);
   out << "\n\nInterestDue : $" << setw(8) << InterestDue << endl;
   out <<  "  TotalAmountDue  : $" << setw(8) << TotalAmountDue << endl;
   out <<  "Payment   : $" << setw(8) << Payment<< endl;
  
}

I create this code but every time try to compile is say error "create pointer to member". Why am i getting this error and how it to compile. Please help.sorry if i don't post code right.

Code tags: it's simple. Type:

[code]

//paste your code in here Type:

[/code]
(or highlight your entire code and click on the [code] button on the editor toolbar.

Now, there's a simple error hampering your progress here:

void open_input(ifstream& input, char name[])[COLOR="Red"][B];[/B][/COLOR]

(that would have been on line 37 had you put code tags)
Again you're still missing a semicolon here as you were told in the other thread. Always start with the first error, correct it and some of the others will fall away as a result.

There are still problems with your output method. What are InterestDue,TotalAmountDue and Payment? How would we normally call (invoke) such things?

#include <iostream>
#include <fstream> // I/O
#include <iomanip> // For setw()
using namespace std;

ofstream     outputfile("output.txt");     // Output file

const int MAX_FILE_NAME = 35;
const double INTEREST_RATE1 = 0.010;
const double INTEREST_RATE2 = 0.010;
const double LEVEL_ONE_BALANCE = 1000.00;
const double MINIMUM_PAYMENT = 10.00;
const double MINIMUM_PAYMENT_PERCENT = 0.10;

{
if balance > 1000 then
     interest = ( balance - 1000) * 1.0% + 1000 * 1.5 %
else
    interest = balance * 1.5 %
end if

total amount due = balance + interest

minimum payment = balance * 10%  
if  total amount due < 10                         
	minimum payment = total amount due

else
     if minimum payment < 10 then      
            minimum payment = 10;
end if}
                                          


class Account
{
public:
Account( double Balance, double InterestRate1, double InterestRate2);
Account( );
double Payment();
double InterestDue();
double TotalAmountDue();
void output(ostream &out); // Print values on output stream out(); 

private:
double balance;
double interest;
double payment;
double interest_rate1;
double interest_rate2;
double total_amount_due;
};


void open_input(ifstream& input, char name[]);
void process_file(ifstream& input);

int main ()

{ 
char again;
char file_name[MAX_FILE_NAME + 1];
ifstream input_numbers;

cout << "This program calculates Balance\n" << endl;
system("pause");

	do
	{
		system ("cls");
		open_input(input_numbers, file_name);
		process_file(input_numbers);
		input_numbers.close();

		cout << "\n Another File?" << endl;
		cin >> again;
		cin.ignore(256, '\n');	
	}
	while (again == 'y' || again == 'Y');


		cout << "\nEnd!!!!!" << endl;
		outputfile << "\nThanks for using program";
		outputfile.close();

		return 0;}

		void open_input (ifstream& input, char name[])

		{
			int count = 0;

		do
		{ count++; 
			if (count !=1)
			{ cout << "\n\aInvalid file or it does not exist." << endl;
	
		}

		cout << "\nEnter the input file name,please. (maximum of " << MAX_FILE_NAME
			<< " characters please)\n:>";
		cin.get(name, MAX_FILE_NAME + 1);
		cin.ignore(256, '\n');
		input.clear();
		input.open(name,ios_base::in);
		}
		while (input.fail() );
}

	void process_file(ifstream& input)

		{
			double value;

		Account thisAccount;
		while (input >> value)
		{
			thisAccount = Account (value, INTEREST_RATE1, INTEREST_RATE2);

			thisAccount.output(cout);
			thisAccount.output(outputfile);
		}
}

			Account::Account ( double Balance, double InterestRate1, double InterestRate2)

			{ 
				balance = Balance;
				interest_rate1 = InterestRate1;
				interest_rate2 = InterestRate2;
					Payment();
			}

			Account::Account()
			{
				balance = 0;
			}
double Account::InterestDue()
{ 
	return interest;
}

double Account::TotalAmountDue()
{
return 4;
}

double Account::Payment( )
{

double newbalance; 

if ( balance > LEVEL_ONE_BALANCE)
     interest = (balance - LEVEL_ONE_BALANCE) * interest_rate2 + LEVEL_ONE_BALANCE * interest_rate1;
else
     interest = balance * interest_rate1;

newbalance = balance + interest;

payment = newbalance* MINIMUM_PAYMENT_PERCENT;

if ( newbalance < MINIMUM_PAYMENT)
     payment = newbalance;
else
     if ( payment < MINIMUM_PAYMENT)
          payment=MINIMUM_PAYMENT;

return payment;
}
void Account::output(ostream &out)

{  out.setf(ios::fixed);      out.setf(ios::showpoint);     out.precision(2);
   out << "\n\nInterestDue : $" << setw(8) << InterestDue << endl;
   out <<  "  TotalAmountDue  : $" << setw(8) << TotalAmountDue << endl;
   out <<  "Payment   : $" << setw(8) << Payment<< endl;
  
}

Are talking about doing this? hope this is what i need to do.

Excellent with the code tags. The rest of it, I'm not sure what you did. You seem to have tossed in some pseudocode ("end if"??) up at the top. You corrected what is now on line 55, which was good, but you haven't corrected anything in your Account::output method. What kinds of errors are you getting now (besides the treasure trove from putting that p-code there)?

ok so i'm missing something or value here:

{  out.setf(ios::fixed);      out.setf(ios::showpoint);     out.precision(2);
   out << "\n\nInterestDue : $" << setw(8) << InterestDue << endl;
   out <<  "  TotalAmountDue  : $" << setw(8) << TotalAmountDue << endl;
   out <<  "Payment   : $" << setw(8) << Payment<< endl;

so adding pseudo code was a bad idea?
Thank you for all the help.

Lines 15-31 in your code above would be what I would call pseudocode. If you're having issues with your code not compiling it's best not to add in more lines that it's going to reject, is all.

Regarding the snippet you just posted. InterestDue, TotalAmountDue, and Payment are all functions. You know how to call a function, you've called one on line 73 (and many others) in the code you posted before. If these functions are to return the values they promised and then send them along into the output stream they need to be invoked properly. Hint: just add ().

double Account::InterestDue(double InterestDue)
{ 
	return interest;
}
 
double Account::TotalAmountDue(double TotalAmountDue)
{
return 4;
}
 
double Account:: Payment(double Payment )
{

Should i be doing it like this?

Do those functions take any arguments? No. So don't add in arguments where they are not necessary.

You're calling a function, you must use the (). So InterestDue should be InterestDue() just as if you had invoked it anywhere else.

{  out.setf(ios::fixed);      out.setf(ios::showpoint);     out.precision(2);
   out << "\n\nInterestDue : $" << setw(8) << InterestDue() << endl;
   out <<  "  TotalAmountDue  : $" << setw(8) << TotalAmountDue() << endl;
   out <<  "Payment   : $" << setw(8) << Payment()<< endl;

So i should add () like this to invoke the function?

Yes

thank you very much for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.