Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help getting it to be continous . After it displays the output for the us

ID: 3817565 • Letter: I

Question

I need help getting it to be continous . After it displays the output for the user. I want it to ask the user if he or she would like to run again,(if yes) and then make it loop back to ask the same user for another loan amount, interest and years. And if they choose NO, to end the program. Please help me.

It's a Mortgage calculator program.

My code is here

#include "stdafx.h"
#include <stdio.h>
#include <math.h>

int main(void)
{
   double principle, toprinciple, principal;
   double annual_rate;
   double monthly_rate;
   double interest_accrued;
   double payment = 1;
   int month = 1;
   int year, n;
   char myname[40] = "Jordan";
   char username[40];
   //title
   printf("******************************************************************************** ");
   printf("*******************************MORTGAGE CALCULATOR****************************** ");
   printf("******************************************************************************** ");
   printf(" "); //creates a blank line
   printf(" ");
   printf("Welcome to my Mortgage program! My name is %s. ", myname);
   printf("Please enter your name. ");
   scanf_s("%s", username, 40);
   printf(" Enter principle amount of the loan, %s: ",username);
   scanf_s("%lf", &principle);
   printf(" Enter annual interest rate,%s (ex:5%%) ",username);
   scanf_s("%lf", &annual_rate);
   printf(" %s, Please enter the term in years (ex. 20) and press ENTER ",username);
   scanf_s("%d", &year);
   printf(" ");
   printf(" ");
   monthly_rate = annual_rate / 1200;
   payment = (principle*annual_rate / 12 / 100 * (pow(1 + annual_rate / 12 / 100, year * 12) / (pow(1 + annual_rate / 12 / 100, year * 12) - 1))) + 0.01;
   n = (year * 12) - 3;
   printf("Principle=%.2f rate=%.2f%% %.3f ", principle, annual_rate, annual_rate / 1200);
   printf("Pay/month=%.2f Years=%d %d", payment, year, year * 12);
   printf(" ");
   printf(" ");
   printf(" Month Principle Interest $ to principle Prin Balance");
   printf(" -------------------------------------------------------------------------- ");

   int i = 1;

   while (principle > 0)
   {
       principal = principle;
       interest_accrued = principle * monthly_rate;
       principle = principle + interest_accrued - payment;
       toprinciple = payment - interest_accrued;
       if ((i<4) || ((i>(year * 12 - 3)) && (i <= (year * 12))))
       {
           printf(" %d $%.2f $%.2f $%.2f $%.2f", month, principal, interest_accrued, toprinciple, principle);
       }
       month++;
       i++;
   }

   printf(" ------------------------------------------------------------------------- ");

   return 0;
}

Explanation / Answer

#include using namespace std; int main() { double monthlyPayment; double balance; double interestRate; int month = 1; cout.setf(ios::fixed); // These lines force currency format in output to 2 decimal pts cout.setf(ios::showpoint); cout.precision(2); cout > balance; cout > interestRate; cout > monthlyPayment; while (interestRate >= 1) { interestRate = interestRate / 100; } balance = balance * (1 + interestRate / 12) - monthlyPayment; // this is where the program stops. cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote