Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double paymentCheck (double, double);
- double totalPaid (double, double, double);
- int main() {
- double loan = 0, loanTwo, rate = 0, rateTwo = 0, payment = 0, paymentTwo = 0, total = 0, totalTwo = 0;
- cout<<"What is the loan amount of the first loan, the annual interest rate, and the monthly payment? \n";
- cin>> loan >> rate >> payment;
- while(paymentCheck(loan, rate) > payment){
- cout<<"The monthly payment is too low. Enter a higher amount. \n";
- cin>> payment;
- }
- total = totalPaid(loan, rate, payment);
- cout<< "\n";
- cout<<"What is the loan amount of the second loan, the annual interest rate, and monthly payments? \n";
- cin>> loanTwo >> rateTwo >> paymentTwo;
- while(paymentCheck(loanTwo, rateTwo) > paymentTwo){
- cout<<"The monthly payment is too low. Enter a higher amount. \n";
- cin>> paymentTwo;
- }
- totalTwo = totalPaid(loanTwo, rateTwo, paymentTwo);
- cout<<"\n";
- if (loan > loanTwo){
- cout<<"Difference between the two loans is " << (loan-loanTwo) << " with the first loan being the bigger amount. (" << loan << " vs " << loanTwo << ") \n";
- } else if (loan < loanTwo){
- cout<<"Difference between the two loans is " << (loanTwo-loan) << " with the second loan being the bigger amount. (" << loan << " vs " << loanTwo << ") \n";
- } else {
- cout<<"The loans are the same amount. (" << loan << " vs " << loanTwo << ") \n";
- }
- if (rate > rateTwo){
- cout<<"Difference between the two rates is " << (rate-rateTwo) << " with the first rate being the bigger amount. (" << rate << " vs " << rateTwo << ") \n";
- } else if (rate < rateTwo){
- cout<<"Difference between the two rates is " << (rateTwo-rate) << " with the second rate being the bigger amount. (" << rate << " vs " << rateTwo << ") \n";
- } else {
- cout<<"The rates are the same amount. (" << rate << " vs " << rateTwo << ") \n";
- }
- if (payment > paymentTwo){
- cout<<"Difference between the two payment is " << (payment-paymentTwo) << " with the first payment being the bigger amount. (" << payment << " vs " << paymentTwo << ") \n";
- } else if (payment < paymentTwo){
- cout<<"Difference between the two payments is " << (paymentTwo-payment) << " with the second payment being the bigger amount. (" << payment << " vs " << paymentTwo << ") \n";
- } else {
- cout<<"The payments are the same amount. (" << payment << " vs " << paymentTwo << ") \n";
- }
- cout<< "This is what you pay in total for the first loan. : " << total << " \n" << "This is what you pay for in total for the second loan. : " << totalTwo << " \n";
- if (total > totalTwo){
- cout<<"Difference between the two totals is " << (total-totalTwo) << " with the first total being the bigger amount. (" << total << " vs " << totalTwo << ") \n";
- } else if (total < totalTwo){
- cout<<"Difference between the two total is " << (totalTwo-total) << " with the second total being the bigger amount. (" << total << " vs " << totalTwo << ") \n";
- } else {
- cout<<"The totals are the same amount. (" << total << " vs " << totalTwo << ") \n";
- }
- return 0;
- }
- double paymentCheck (double loan, double rate){
- double interest = ((rate/100) / 12) * loan;
- return interest;
- }
- double totalPaid (double loan, double rate, double payment){
- double amount = 0;
- double monthlyRate = (rate/100) / 12;
- while (loan >= payment){
- loan = ((loan * monthlyRate) + loan) - payment;
- amount = amount + payment;
- }
- amount = amount + loan;
- return amount;
- }
Advertisement
Add Comment
Please, Sign In to add comment