Hi,
I'm trying to write a program that computes interest and check fees and then prints a new calculated balance. So far it works okay, but seems like I have a lot of unnecessary work. Can someone help me simplify it down plz?

ps: The premium acct has no check fees, but the standard one does. premium=p, standard=s;
Premium acct gives .05 interest if the account is above 5k or .03 if it is under.

#include <iostream>
#include <conio.h>

using namespace std;


int main()
    {
        
        
        
        double FIVE = 5000.00;
        const double LOW_INTEREST = 0.03;
        const double HIGH_INTEREST = 0.05;
        const double CHECK_FEE = 0.10;
        char acct_type;
        bool okay = true, notOkay = false;
        
    
        do 
        {
        cout << "What type of account is this: " << endl;
        cout << "Type 's' for a standard account: " << endl;
        cout << "Type 'p' for a premium account: " << endl;
        cin >> acct_type;
        
        cin.ignore(80, '\n');
        okay = (acct_type == 's' || acct_type == 'p');
        if (!okay)
            cout << "\nYou entered an invalid account type!" << endl;
        }while(!okay);
        
        
        
        double earned_interest;
        double fees;
        double newbalance;
        double balance;
        int checks;
        
        if (acct_type == 'p') {
            
        cout << "Enter in the ending balance for this month: " << endl;
        cin >> balance;
        if (balance >= FIVE)
        earned_interest = balance * HIGH_INTEREST;
        else earned_interest = balance * LOW_INTEREST;
        
        
        if (balance < FIVE) {
        cout << "Enter in the number of checks written this month: " << endl;
        cin >> checks;
        fees = checks * CHECK_FEE;
        
        
        newbalance = balance - fees + earned_interest;
            cout << "\nThe new ending balance is: " << "$" << newbalance << endl;
        }else
        newbalance = balance + earned_interest;
            cout << "\nThe new ending balance is: " << "$" << newbalance << endl;
}         
        if (acct_type == 's')
        cout << "Enter in the ending balance for this month: " << endl;
        cin >> balance;
        cout << "Enter in the number of checks written this month: " << endl;
        cin >> checks;
            earned_interest = balance * LOW_INTEREST;
            fees = checks * CHECK_FEE;
            newbalance = balance - fees + earned_interest;
            cout << "\nThe new ending balance is: " << "$" << newbalance << endl;
        
        //getch();
        return 0;
}

What kind of optimization do you want to perform on this code, performance wise or lengthwise ? Please be more specific.

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.