Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Anybody knows what's the problem is it the interest rate? When i run the program it gives me
ld.exe||cannot open output file bin\Debug\Assignemts.exe Permission denied|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 5 seconds) ===|


What I have tried:

C++
#include <iostream>
#include <iomanip>
#include <stdlib.h>

using namespace std;
class bank_account
{
public:
    bank_account();
    bank_account(int account_no, float opening_balance);
    void get_interest(float interest_rate);
    void balance(float amount);
    void deposit(float amount);
    void withdrawal(float amount);
    void display_bank_report();
    void display_headings();
private:
    int dm_account_no;
    float dm_balance;
    float dm_interest_rate;
    float dm_interest_earned;
    float dm_total_balance;
    float dm_total_interest;
};
bank_account::bank_account()
{
dm_account_no=0;
dm_balance = 0;
}
bank_account::bank_account(int account_no, float opening_balance)
{
    dm_account_no = account_no;
    ///Must Add 10% To Opening balance
    dm_balance = opening_balance *1.1;
}

void bank_account::deposit(float amount)
{
    dm_balance = dm_balance + amount;
}
void bank_account::withdrawal(float amount)
{
    dm_balance = dm_balance - amount;
}
void bank_account::get_interest(float interest_rate)
{
    dm_interest_rate= interest_rate;
    dm_interest_earned = dm_interest_rate * dm_balance;

}
void bank_account::display_bank_report()
{
cout<<left<<setw(15)<<dm_account_no <<setw(15)<< dm_balance << setw(15) << dm_interest_rate<< endl;
}
void bank_account::display_headings()
{
cout<<left<<setw(15)<<"Account" <<setw(15)<< "Closing" << setw(15) << "Interest"<< endl;
cout<<left<<setw(15)<<"Number" <<setw(15)<< "Balance" << setw(15) << "Earned"<< endl;

}

int reply;
int account_no [4] = {80045001, 80045002, 80045003, 80045004};
float opening_balance [4] = {100, 200, 300, 400};
float deposit1 [4] = {100, 200, 300, 400};
float deposit2 [4] = {10, 200, 300, 400};
float withdrawal1 [4] = {50, 50, 50, 50};
float withdrawal2 [4] ={155, 50, 50, 50};
float get_interest [4] = {.01, .02, .03, .04};

int main()
{
    system ("COLOR A4");

    bank_account account1(account_no[0], opening_balance[0]);
    bank_account account2(account_no[1], opening_balance[1]);
    bank_account account3(account_no[2], opening_balance[2]);
    bank_account account4(account_no[3], opening_balance[3]);
    bank_account account5;

    account1.deposit(deposit1[0]);
    account2.deposit(deposit1[1]);
    account3.deposit(deposit1[2]);
    account4.deposit(deposit1[3]);

    account1.withdrawal(withdrawal1[0]);
    account2.withdrawal(withdrawal1[1]);
    account3.withdrawal(withdrawal1[2]);
    account4.withdrawal(withdrawal1[3]);

    cout<< "Do you want to continue Yes or not"<<endl;
    cout<< "Enter Y to continue or N to exit"<<endl;
    cin>>reply;

    if (reply == 'N'){
        cout<<"Goodbye!"<<endl;
        exit(EXIT_FAILURE);}
    cout<<"Continue processing"<<endl;

    account1.deposit(deposit2[0]);
    account2.deposit(deposit2[1]);
    account3.deposit(deposit2[2]);
    account4.deposit(deposit2[3]);

    account1.withdrawal(withdrawal2[0]);
    account2.withdrawal(withdrawal2[1]);
    account3.withdrawal(withdrawal2[2]);
    account4.withdrawal(withdrawal2[3]);

    cout<< "Bank Account System"<< endl;
    account1.display_headings();
    account1.display_bank_report();
    account2.display_bank_report();
    account3.display_bank_report();
    account4.display_bank_report();
    account5.display_bank_report();
    return 0;
}
Posted
Updated 11-Jan-18 21:09pm
v3
Comments
Patrice T 11-Jan-18 18:18pm    
try to describe what is not as expected.
Peter_in_2780 11-Jan-18 18:18pm    
So. You've given us a code dump, no clues as to what you expect to happen or what actually did happen. If you want an answer, the first requirement is a question. the better the question, the better the answer is likely to be.
PIEBALDconsult 11-Jan-18 19:47pm    
Doesn't sound code-related so no point posting the code.
Mohibur Rashid 11-Jan-18 23:15pm    
what tools are you using?

Your problem is not the code, but something on your file system. My best guess is that your IDE hasnt the right to write the ld.exe or the ld.exe is running and or locked.

Try to delete the ld.exe by hand (or taks manager) and rebuild. Else set another output directory.

Tip: use a constant and loops like in my sample code to improve your code

C++
const int COUNT_ACCOUNT = 4;
float deposit1 [COUNT_ACCOUNT] = {100, 200, 300, 400};
// in the functions
for( int i = 0; i < COUNT_ACCOUNT; i++ ) {
  deposit1[i] = 0;
}
 
Share this answer
 
The error message
ld.exe||cannot open output file bin\Debug\Assignemts.exe Permission denied
is quite clear.

ld.exe is the linker of the GCC (Gnu Compiler Collection). A linker puts the compiled source files and libraries together and creates the final executable. It is usually not called directly but when executing the compiler gcc (or g++ in your case) with linking parameters. In your case, it has no write permission to the output directory bin\Debug\. The back slashes in the path indicate that you are using Windows. So you have to ensure that the user account executing the linker or compiler (probably your user account) is allowed to write to that directory.

Such may happen if you are using some kind of IDE (Integrated Development Environment) and created or used your project within the IDE using different accounts.

As a quick solution you may start the Windows Explorer and check the permissions of that directory (it is a relative directory and can probably be found below the project directory). To change the permission within the Explorer, you have to start it as the user who owns the directory or as administrator. Then select the project directory and apply the same ownership and permissions to that directory and all sub directories.
 
Share this answer
 
Did you try Google[^]?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900