Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new file ex2_2.cpp added #801

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions ch02/ex2_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//AUTHOR YASH PARSANA
//DATE 11-05-2021
//CALCULATOR To calculate a mortgage payment

#include<iostream>
using std::cin;
using std::cout;
using std::endl;

float po(float r,int n)
{
float ans=1;

for(int z=1;z<=n;z++)
{
ans*=r;
}
return ans;
}
int main()
{
float p_amount,rate; // FLOAT TAKES HALF SPACE AS COMPARE TO DOUBLE AND HERE HAVE NO REQUIREMENT OF DOUBLE
int year;

cout<<"Please Enter principal Amount : ";
cin>>p_amount;
cout<<endl<<"Please Enter rate of interest : ";
cin>>rate;
cout<<endl<<"Please Enter duration (in year) : ";
cin>>year;
cout<<endl;

int n=year*12;

rate=rate/1200;

float temp=po(1+rate,n);

float payment=(p_amount*rate*temp)/(temp-1);

cout<<"Your monthly payment is : "<<payment<<endl;




return 0;
}