I'm missing some key basic concepts here that I thought I understood with functions, pass by value, pass by reference. I tried deleting most of my parameters, to no avail, I took out my multiple returns, and fooled around with pass by reference.....I keep getting an address for my min_payment output...I REALLY NEED to understand this as I am coming close to class beginning and it focuses on debugging and depends on a good foundation in the basics. I read my text from last semester, but it often gets me confused:
#include <iostream>
using namespace std;
double balance, balance1, balance2, payment, total_due1;
double rate_maker(double balance1, double balance2, double& total_due1);
double min_payment(double payment,double& total_due1);
double rate_maker(double balance1, double balance2, double& total_due1)
{
if(balance <= 1000)
{
balance1 = balance * .015;
total_due1 = balance1;
}
else if(balance > 1000)
{
balance1 = (1000 * .015);
balance2 = (balance - 1000 * .01);
total_due1 = balance1 + balance2;
return total_due1;
}
}
double min_payment(double payment, double& total_due1)
{
if(total_due1 <= 10)
{
payment = total_due1;
}
else if(10 < total_due1 * .01)
{
payment = total_due1 * .01;
}
else
{
payment = 10;
return payment;
}
}
int main()
{
double interest, monthly, owed, bal1=0, bal2=0, pay=0;
cout << "Please enter your current balance: " << endl;
cin >> balance;
interest = rate_maker(bal1,bal2,owed);
cout << "Your total due is: " << interest << endl;
monthly = min_payment(pay,owed);
cout <<"Your monthly payment is: " << monthly << endl;
int x;
cin >> x;
return 0;
}