#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.