3 Replies - 6318 Views - Last Post: 10 March 2011 - 09:41 PM Rate Topic: -----

#1 Karl_III   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 15
  • Joined: 05-March 11

Monthly Mortgage Payment Calculator . . . . impossible?

Posted 10 March 2011 - 09:18 PM

Hey guys, I have to create a C++ program that prompts the use to enter and amount two things. It asks the user for the Mortgage amount and the interest rate and from there it does the math to figure out the monthly payments, I did it correctly, or so I thought. Now the code wont compile, can you please tell me what I did wrong and how to fix it? THANKS GUYS!

My Code:
#include <iomanip>
#include <iostream>
using namespace std;

#include <cmath>
 
int main()
{
  double years = 30;
  
  double M; 
  cout << "What's the mortgage amount? "; 
  cin >> M; 
  cin.ignore(1000, 10);

  double I; 
  cout << "What's the annual interest rate? "; 
  cin >> I; 
  cin.ignore(1000, 10);

  double A = I/12;
  double T = years * 3;

  double prob1 = (M*(1+I)T*I);
  double prob2 = ((1+I)T-1);
  double W = prob1/prob2;

  cout << fixed; 

  cout << "its " << W << endl;
  
  return 0;
}


MOD EDIT: When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 11 March 2011 - 06:01 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Monthly Mortgage Payment Calculator . . . . impossible?

#2 r.stiltskin   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2034
  • View blog
  • Posts: 5,436
  • Joined: 27-December 05

Re: Monthly Mortgage Payment Calculator . . . . impossible?

Posted 10 March 2011 - 09:22 PM

The compiler hasn't been taught implicit multiplication. When you want to multiply two expressions you have to put a multiplication operator * between them.
Was This Post Helpful? 0
  • +
  • -

#3 Karl_III   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 15
  • Joined: 05-March 11

Re: Monthly Mortgage Payment Calculator . . . . impossible?

Posted 10 March 2011 - 09:39 PM

Which part of the code were you referring to when you mentioned the multiplication? Could you possibly post the equation for me in the correct way?
Was This Post Helpful? 0
  • +
  • -

#4 r.stiltskin   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2034
  • View blog
  • Posts: 5,436
  • Joined: 27-December 05

Re: Monthly Mortgage Payment Calculator . . . . impossible?

Posted 10 March 2011 - 09:41 PM

(1+I)T should be (1+I)*T

That is, assuming you're actually supposed to be multiplying (1+I) times T. I didn't mean to imply that I have checked your formulas or your logic (I haven't). I was only looking at your syntax to find the reason for compilation errors.

This post has been edited by r.stiltskin: 10 March 2011 - 10:08 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1