I will be taking a c++ class in the fall so I decided to do some self-studying. I took a programming logic and design class the previous semester and have been writing pusdo-code. But now I want to translate that into C++.
I wrote a program to calculate over drawn fees. The goal was to use it to practice passing variables between modules.
I got the program to work but I was wondering if I have extra code in there. I want to return variables to the main program without me needing to pass variables from the main() to the other modules.
Do I need these two variables to make my program work?
double accountBalance=0; double overDrawn=0; If you guys have any other tips for me to make my code cleaner please let me know. Thank you!
#include <iostream>
#include <cmath>
using namespace std;
// Page 83
// Exercise 5
// The program determines a monthly checking account fee. 
//Declaration of all the modules
int acctBalInput(double acct);
int overdrawInput(double draw);
int feeCalculation(int bal, int draw);
void display(int bal, int draw, int fee);
//Main function
int main()
{
     //Declarations
    double accountBalance=0;
    double overDrawn=0;
    double balance;
    double drawn;
    double totalFee;
    balance = acctBalInput(accountBalance);
    drawn = overdrawInput(overDrawn);
    totalFee = feeCalculation(balance, drawn);
    
    display(balance, drawn, totalFee);
    return 0;
}
//Input account balance.
int acctBalInput(double acct)
{
    cout << "Enter account balance: ";
    cin >> acct;
    return acct;
}
//Input overdrawn times.
int overdrawInput(double draw)
{ 
    cout << "Enter the number of times over drawn: ";
    cin >> draw;
    return draw;
}
//Calculates the total fee.
 int feeCalculation( int bal, int draw)
 {
    int fee;
    int feePercent = 0.01;
    int drawFee = 5;
    fee =(bal*feePercent)+(draw*drawFee);
    return fee;
 }
 //Displays all the ouput.
 void display(int bal, int draw, int fee)
 {
    cout <<"Balance: "<< bal<< endl
    <<"Overdrawn: "<< draw << endl
    <<"Fee: " << fee << endl;
    return;
 }
I tried googling to see a better way to write my code.
