C/C++ Mortgage...Some Serious Help

I'm a newbie and i'm at a lost, it's not running or anythi

Page 1 of 1

1 Replies - 1314 Views - Last Post: 27 October 2006 - 04:28 AM Rate Topic: -----

#1 SlightlyAngelic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-October 06

C/C++ Mortgage...Some Serious Help

Posted 27 October 2006 - 04:00 AM



#include<stdio.h>
#include<math.h>


# define I 0.0765	//Interest Rate




//Prototypes
double Mortgage_Calc(void);
void Financial_Report(void);

int main() {
   
 char fname[20];
  char lname[20];
  float loan = 0.0;
  int years;
  double PB;
 

	 printf("  *******************Caribbean Mortgage Company*************\n\n\n\n\n");
	
	 printf("Enter the Customer's Name (First Name and Surname)\n");
	 scanf("%s%s",&fname,&lname);
	
	 printf("Enter Requested Loan Amount\n");
	 scanf("%f",&loan);
	
	 printf("Enter Number of Years for Mortgage\n");
	 scanf("%d",&years);
	 Mortgage_Calc();
	 Financial_Report();
	 return(0);
}


double Mortgage_Calc(double PB, double A, double Y) 

{

  //PB : payback
  //A :Amount Loaned
 //Y:Number of Years over which the mortgage extends
	
	
   
	PB = A * pow((1 + I), years); 


	/*A*1.0+ I/100;
	A=exp(Y);
	PB=A;
	years=Y;
	principal * pow((1 + rate), (double)years); */

	return(PB);
}


void Financial_Report()
 {
	 printf("  *******************Caribbean Mortgage Company*************\n");
	 printf("  ************************Financial Report******************\n\n\n\n\n");
	 printf("Applicant's Name: %s %s", &fname,&lname);
	 printf("Requested Loan Amount: %f",&loan);
	 printf("Interest Rate: 7.65 percent");
	 printf("Number of Years for Mortgage: %d", &years);
	 printf("Total Amount to be Paid Back: %f",&PB);
	// printf("The Monthly Installments are: 
	

}

}





1. It will run to the point of asking the user of the loan amount and then it will crash.

2. I don't know how to call a function within a function; hence the main is to ask for the information, the information given to go into Mortgage_Calc to be calculated then for the output/calculations to be displayed in the Financial Report.

But i'm at a complete lost.

There can't be any global variables, must be functionally decomposed and modular...and i think that is what i've been doing so far.......

Is This A Good Question/Topic? 0
  • +

Replies To: C/C++ Mortgage...Some Serious Help

#2 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: C/C++ Mortgage...Some Serious Help

Posted 27 October 2006 - 04:28 AM

I think your code won't even compile. Your function decleration for Mortgage_Calc double Mortgage_Calc(void); and defination double Mortgage_Calc(double PB, double A, double Y) does not match.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1