What is wrong with this code?


Can anyone figure out what is wrong with this program?
I am using an ebook to learn C++ and this is exactly what the code looks like in the book. Every time i run it in Dev C++ it comes up with tons of errors.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
   Project 2-3 compute the 
   regular payments on a loan
*/

#include <iostream>
#include <cmath>
using namespace std;

double Principal; // original principal
double IntRate; // interest rate
double PayPerYear; // number of payments per year
double NumYears; // number of years
double Payment; // the regular payment
double numer, denom; // temporary work variables
double b, e; // base and exponent for call to pow()

cout << "Enter principal: ";
cin >> Principal;

cout << "Enter interest rate (i.e., 0.075): ";
cin >> IntRate;

cout << "Enter number of payments per year: ";
cin >> PayPerYear;

cout << "Enter number of years: ";
cin >> NumYears;

numer = IntRate * Principal / PayPerYear;

e = -(PayPerYear * NumYears);
b = (IntRate / PayPerYear) + 1;

denom = 1 - pow(b, e);

Payment = numer / denom;

cout << "Your payment is $" << Payment;

cin.get();
return 0;
}
You're missing int main() { after line 9 I believe.
Oh wow, I don't know how I missed that... Lesson learned: Take breaks!
Topic archived. No new replies allowed.