Question

How do I get this code to output The monthly payment is too low resulting in...

How do I get this code to output The monthly payment is too low resulting in the loan amount not being able to be repaid, if the monthly payment is not higher than the interest rate. Right now I cant get it to say that.

#include <iostream>
using namespace std;
int main()
{
   double monthlyPayment;
   double remainingBalance;
   double interestRate;
   int month = 1;
   cout.setf(ios::fixed);
   cout.setf(ios::showpoint);
   cout.precision(2);
   cout << "Enter loan amount: $";
   cin >> remainingBalance;
   cout << "Enter interest rate : ";
   cin >> interestRate;
   cout << "Enter desired monthly payment : $";
   cin >> monthlyPayment;
   while (interestRate >= 1)
   {
       interestRate = interestRate / 100;
   }
   do
   {
       remainingBalance = remainingBalance * (1 + interestRate / 12) - monthlyPayment;
       cout << "After month " << month << ", your balance is : $" << remainingBalance << endl;
       month++;
   } while (remainingBalance > 0);
   if (monthlyPayment > interestRate)
   {
       cout << "Your loan is officially paid off" << endl;
   }
   else
   {
       cout << " The monthly payment is too low resulting in the loan amount not being able to be repaid" << endl;
   }
  
   return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note : Updates are Highlighted.

#include <iostream>
using namespace std;
int main()
{
double monthlyPayment;
double remainingBalance;
double interestRate;
int month = 1;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Enter loan amount: $";
cin >> remainingBalance;
cout << "Enter interest rate : ";
cin >> interestRate;
cout << "Enter desired monthly payment : $";
cin >> monthlyPayment;
while (interestRate >= 1)
{
interestRate = interestRate / 100;
}
do
{
remainingBalance = remainingBalance * (1 + interestRate / 12) - monthlyPayment;
cout << "After month " << month << ", your balance is : $" << remainingBalance << endl;
month++;
} while (monthlyPayment > ((interestRate*remainingBalance)/12) && remainingBalance > 0);
if (monthlyPayment > ((interestRate*remainingBalance)/12))

{
cout << "Your loan is officially paid off" << endl;
}
else
{
cout << " The monthly payment is too low resulting in the loan amount not being able to be repaid" << endl;
}
  
return 0;
}

If you put inputs like this u get desired output

C:\HomeworkLib>mpay
Enter loan amount: $500
Enter interest rate : 10
Enter desired monthly payment : $50
After month 1, your balance is : $454.17
After month 2, your balance is : $407.95
After month 3, your balance is : $361.35
After month 4, your balance is : $314.36
After month 5, your balance is : $266.98
After month 6, your balance is : $219.21
After month 7, your balance is : $171.03
After month 8, your balance is : $122.46
After month 9, your balance is : $73.48
After month 10, your balance is : $24.09
After month 11, your balance is : $-25.71
Your loan is officially paid off

C:\HomeworkLib>mpay
Enter loan amount: $50000
Enter interest rate : 22
Enter desired monthly payment : $900
After month 1, your balance is : $50016.67
The monthly payment is too low resulting in the loan amount not being able to be repaid

C:\HomeworkLib>

Screens:

Add a comment
Know the answer?
Add Answer to:
How do I get this code to output The monthly payment is too low resulting in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA: amortization table: Hi, I have built this code and in one of my methods: printDetailsToConsole...

    JAVA: amortization table: Hi, I have built this code and in one of my methods: printDetailsToConsole I would like it to print the first 3 payments and the last 3 payments if n is larger than 6 payments. Please help! Thank you!! //start of program import java.util.Scanner; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.lang.Math; //345678901234567890123456789012345678901234567890123456789012345678901234567890 /** * Write a description of class MortgageCalculator here. * * @author () * @version () */ public class LoanAmortization {    /* *...

  • in c++ Finish the methods in the following code. DO NOT CHANGE THE MAIN METHOD. The...

    in c++ Finish the methods in the following code. DO NOT CHANGE THE MAIN METHOD. The instructions for each method are in a comment in the template. DO NOT CHANGE THE MAIN METHOD!!!! #include <iostream> #include <string> using namespace std; // prototypes int main() { int answer = 0; int value1 = 0; int value2 = 0; double average = 0; string string1 = ""; int numberVowels = 0; int numberNonVowels = 0; cout << "Enter string1: "; getline(cin, string1);...

  • I need to get this two last parts of my project done by tonight. If you...

    I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...

  • c++ Please help! i keep getting an error message. I think my main problem is not...

    c++ Please help! i keep getting an error message. I think my main problem is not understanding the circle calculations function and how both the area and the circumference is returned from the function. I know & needs to be used, but I am unsure how to use it. Copy the following code and run it. You should break it into the following 3 functions getValidinput - which asks the user to enter the radius and then make sure that...

  • How would i be able to use If/else statements on this code for it to give...

    How would i be able to use If/else statements on this code for it to give me a letter grade at the end? #include <iostream> #include <iomanip> using namespace std; int main() { double grade1, grade2, grade3, grade4, total; cout << "please enter the first grade : "; cin >> grade1; cout << "Please enter the second grade : "; cin >> grade2; cout << "Please enter the third grade : "; cin >> grade3; cout << "Please enter the...

  • What does this error message mean? "expected primary expression before int" Also, how do i get...

    What does this error message mean? "expected primary expression before int" Also, how do i get the program to repeat the numbers that were entered by the user back to me? this is my code below: // This program accepts a series of positive numbers // This code was last modified on 2/16/2020 #include <iostream> #include <iomanip> #include <cmath> using namespace std; void welcome(); int entrySubmission(int numbers); void acceptsNumbers(int); void goodbye(); int main() { welcome(); entrySubmission(int numbers); acceptsNumbers(int); goodbye(); return...

  • Need done in C++ Can not get my code to properly display output. Instructions below. The...

    Need done in C++ Can not get my code to properly display output. Instructions below. The code compiles but output is very off. Write a program that scores the following data about a soccer player in a structure:            Player’s Name            Player’s Number            Points Scored by Player      The program should keep an array of 12 of these structures. Each element is for a different player on a team. When the program runs, it should ask the user...

  • How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0,...

    How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • I've created a mortgage calculator and the next step in my project is to include an...

    I've created a mortgage calculator and the next step in my project is to include an array. I'm not very good at C++ as this is my first time taking a programming course. I was able to get this working but I'm confused as to where I could use an array. I was thinking of maybe using the person's credit score as an indication of what their interest rate could be for a HELOC. Something like this : int creditScore[3]={2.8,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT