This first function works, but I have to give the user a monthly payment of either "The minimum payment is the total amount due if that is 10 or less; otherwise, it is 10 or 10% of the total amount owed, whichever is larger." My rate_maker function doesn't pass the value of total_value to min_payment function's variable total_value (everything's 0's)?? Once again, I'm at an impasse!
Thank you for any help:

#include <iostream>
using namespace std;

		double rate1, rate2, payment, balance, balance1, balance2, total_due;

		double rate_maker(double rate1, double rate2, double balance, double balance1, double balance2, double total_due);
		double min_payment(double total_due,double payment);

		double rate_maker(double rate1, double rate2,double balance, double balance1,double balance2, double total_due)
			if(balance <= 1000)
			balance1 = balance * .015;
			total_due = balance1;
			return total_due;

			else if(balance > 1000)
			balance1 = (1000 * .015);
			balance2 = (balance - 1000 * .01);
			total_due = balance1 + balance2;
			return total_due

		double min_payment(double total_due, double payment)

		if(total_due <= 10)
			payment = total_due;
			return payment;
		else if(10 < total_due * .01)
			payment = total_due * .01;
			return payment;
			payment = 10;
			return payment;

	int main()
		double interest, monthly;

		cout << "Please enter your current balance: " << endl;
		cin >> balance;
		interest = rate_maker(rate1,rate2,balance,balance1,balance2,total_due);
		cout << "Your total due is: " << interest << endl;
		cin >> total_due;
		monthly = min_payment(total_due,payment);
		cout <<"Your monthly payment is: " << monthly << endl;

		int x;
		cin >> x;

		return 0;
10 Years
Discussion Span
Last Post by guitarrick

This won't solve your problem but min_payment() needs to be restructured so that there is only one return statement. No need for all those returns -- just put one at the end of the function. Same for min_payment()

Actually, making the above changes did fix the problem. Here is the output

Please enter your current balance:
Your total due is: 1.5
Your monthly payment is: 1
Press any key to continue . . .


Remove all of the parameters. It looks like you're actually expecting the global variables to be the ones that are changed, but when you use function parameters with the same name, they hide the global variables. When the function returns, you haven't changed the global variables at all.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.