im not asking you to do my homework because most of it is already done, i just need some insight on what im doing wrong so that i can fix it. this is my program so far: (pls excuse the comments, the prof wants them there) // Purpose: This program calculates and prints the factorial of a number //---------------------------------------------------------- #include<iostream> usingnamespace std; int Factorial(/* in */int n); // Purpose: This function computes the factorial of a number 'n' // Precondition: n is assigned an integer value // n >= 0 and n! <= INT_MAX // Postcondition: Returns the factorial of n int main() { int number; cout << "*** FACTORIAL ***\n"; cout << "-----------------\n"; cout << " \n"; cout << "Enter a non-negative number whose factorial is to be computed: "; cin >> number; **********cout << "The factorial of " << number << " is " << Factorial(int n) << endl; return 0; } int Factorial(int n) { int result; //hold partial products result = 1; //initialize while (n > 0) //while the value of n is positive { result = result * n; n--; } return result; //return the calculated factorial of n } the line with all the asterisks has all the problems: error c2660: 'Factorial' : function does not take 0 arguments error c2144: syntax error: 'int' should be preceded by ')' error c2059: syntax error: ')' i have another program that also highlights the use of function calls and also has the same problems. tried looking in the textbook but it has a very short section on function calls. is it something to do with my preconditions? any help would be nice. thanks.

error c2660: 'Factorial' : function does not take 0 arguments **********cout << "The factorial of " << number << " is " << Factorial(int n) << endl; You're calling your Factorial function without a proper argument

oops, nevermind. i changed: cout << "The factorial of " << number << " is " << Factorial(number) << endl; and it works

You should be calculating the factorial recursively anyway Code: unsigned int factorial(unsigned int n) { if(n <= 1) return n; else return factorial(n-1) * n; } lol, confused yet?

^^ lol, thanks. how about this one: // Purpose: This program will calculate how long it will take to pay a loan // when only the minimum payment is paid and how much the total // interest payment is. //------------------------------------------------------------------------ #include<iostream> #include<conio.h> usingnamespace std; int main() { double loanAmount; //amount of the loan double principlePay; //amount to pay down principle after interest double annualInterest; //annual interest double monthlyInterest; //monthly interest int minPay; //minimum monthly payment int howManyMonths; //time it takes to pay the loan double totalInterest; //total interest paid double interestPay; //amount of interest paid each month double totalPaid; //total amount paid //set up floating point with 2 digits after the decimal cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); //initializing variables totalInterest = 0; howManyMonths = 0; cout << "PAYING A LOAN\n"; cout << "-------------\n"; cout << " \n"; //prompting user for useful info cout << "Enter the amount of the loan: $"; cin >> loanAmount; cout << " \n"; cout << "Enter the annual percent interest rate of the loan: "; cin >> annualInterest; cout << " \n"; monthlyInterest = annualInterest / 12; cout << "Enter the minimum payment amount: $"; cin >> minPay; cout << " \n"; while (loanAmount >= 0) //checking loop control { interestPay = loanAmount * monthlyInterest; loanAmount = loanAmount - (minPay - interestPay); totalInterest = totalInterest + interestPay; howManyMonths = howManyMonths + 1; } totalPaid = loanAmount + totalInterest; cout << howManyMonths << endl; cout << totalPaid << endl; getch(); return 0; } the build goes fine, but the debug has nothing happen after i punch in the minimal payment.

It worked as is, you need to enter the percent interest as 0.06 for 6%... when I first ran it I entered 6 for 6 percent and that will actually increase the amount you owe faster than you pay it off, making it infinite loop. Additionally, you are not calculating totalPaid right... you are adding totalInterest to loanAmount which seems fine, the only problem is after that loop loanAmount = 0... you need to make another variable to hold loanAmount constant through that loop so it can be added to totalInterest at the end

This takes me back, why didnt i stick with this so i can get paid to do this vs analyzing reroutes and processing ics payments all day?

Because this is the tip of the iceberg, I am in a graduate class called algorithms right now and he might as well be speaking Egyptian for how much I am understanding lol. When you integrate this stuff with calculus 3 and discreet math it is not pretty. you can look at my notes if you want: http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/LectureNotes/

When you call Factorial, you shouldn't create a new "n" variable inside the parentheses. Just give it the "n" variable you've already created.

hey guys, i really do appreciate all the help you given. this is the final code of the second program if anyone cares: // Purpose: This program will calculate how long it will take to pay a loan // when only the minimum payment is paid and how much the total // interest payment is. //------------------------------------------------------------------------ #include<iostream> #include<conio.h> using namespace std; int main() { double loanAmount; //amount of the loan double amountLeftToPay; //amount left to pay double annualInterest; //annual interest double monthlyInterest; //monthly interest int minPay; //minimum monthly payment int howManyMonths; //time it takes to pay the loan double totalInterest; //total interest paid double interestPay; //amount of interest paid each month double totalPaid; //total amount paid //set up floating point with 2 digits after the decimal cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); //initializing variables totalInterest = 0; howManyMonths = 0; cout << "PAYING A LOAN\n"; cout << "-------------\n"; cout << " \n"; //prompting user for useful info cout << "Enter the amount of the loan: $"; cin >> loanAmount; cout << " \n"; amountLeftToPay = loanAmount; cout << "Enter the annual percent interest rate of the loan: "; cin >> annualInterest; cout << " \n"; monthlyInterest = (annualInterest / 12) / 100; cout << "Enter the minimum payment amount: $"; cin >> minPay; cout << " \n"; while (amountLeftToPay >= 0) //checking loop control { if (loanAmount == amountLeftToPay) { interestPay = loanAmount * monthlyInterest; amountLeftToPay = loanAmount - (minPay - interestPay); } else { interestPay = amountLeftToPay * monthlyInterest; amountLeftToPay = amountLeftToPay - (minPay - interestPay); } totalInterest = totalInterest + interestPay; howManyMonths = howManyMonths + 1; totalPaid = loanAmount + totalInterest; } cout << "For the initial loan amount of $" << loanAmount << ",\n"; cout << "it will take " << howManyMonths << " months to pay the loan in full\n"; cout << "with the total of $" << totalPaid << " paid over the life of the loan.\n"; cout << " \n"; getch(); return 0; }