write a program to ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. your program will

Answers

Answer 1

We write a program for this problem using C++.

What is Programming language?

A programming language is a vocabulary and grammar system used to give instructions to a computer or other computing equipment so that it can carry out particular activities. • High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada, and Pascal are referred to as programming languages.

Code for the given problem:

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

void get_input(double& principle, double& interest, double& payment);

/* This function asks the user to input the principle, interest,

and payment amount, and only accepts positive numbers for input.

All three parameters are call-by-reference, so the function

in effect returns the three values by changing the values of

the arguments which are passed to it. The initial values of

these parameters are ignored and overwritten.

*/

double pay_off_loan(double principle, double rate, double payment,

int& months, double& total_interest);

/* This function assumes the payment is enough

to cover first month's interest.  It has a loop to

pay off the loan one month at a time.

Pre-Condition:

principle = starting principle.

rate = monthly interest rate expressed as a decimal.

payment = amount of monthly payment, which must be high

enough to pay off the first month's interest.

Post-Condition:

amount of final payment is returned by the function.

months = number of months it took to pay off loan.

total_interest = total amount of interest paid during

that time.

It may help to think of principle, rate, and payment as

input parameters, and months, and total_interest

as output parameters.

*/

int main()

{

double principle, interest, payment, monthly_rate;

double final_payment, total_interest, monthly_interest;

int months;

get_input(principle, interest, payment);

monthly_rate = interest/12/100;

monthly_interest = principle * monthly_rate;

cout << endl;

cout << fixed << setprecision(2);

if(payment < monthly_interest)

{

cout << "You must make payments of at least $" << 1+monthly_interest << endl;

cout << "Because your monthly interest is $" << monthly_interest << endl;

}

else

{

final_payment = pay_off_loan(principle, monthly_rate, payment, months, total_interest);

cout << "Your debt will be paid off after " << months << " months, with a final payment of just $ " << final_payment << endl;

cout << "The total amount of interest you will pay during that time is $" << total_interest << endl;

}

cout << endl << "** Don't get overwhelmed with debt! **" << endl;

}

void get_input(double& principle, double& interest, double& payment)

{

cout << "How much do you want to borrow? $";

cin >> principle;

while(principle <= 0)

{

cout << "You must enter a positive number!" << endl;

cout << "How much do you want to borrow? $";

cin >> principle;

}

cout << "What is the annual interest rate expressed as a percent? ";

cin >> interest;

while(interest <= 0)

{

cout << "You must enter a positive number!" << endl;

cout << "What is the annual interest rate expressed as a percent? ";

cin >> interest;

}

cout << "What is the monthly payment amount? $";

cin >> payment;

while(payment <= 0)

{

cout << "You must enter a positive number!" << endl;

cout << "What is the monthly payment amount? $";

cin >> payment;

}

}

double pay_off_loan(double principle, double rate, double payment,

int& months, double& total_interest)

{

double final_payment = 0;

double monthly_interest;

months = 0;

total_interest = 0;

while(principle > 0)

{

monthly_interest = principle * rate;

total_interest += monthly_interest;

principle = principle + monthly_interest - payment;

months++;

}

if(principle < 0)

final_payment = principle + payment;

else

final_payment = payment;

return final_payment;

}

Output:

How much do you want to borrow? $15000

What is the annual interest rate expressed as a percent? 11

What is the monthly payment amount? $2500

Your debt will be paid off after 7 months, with a final payment of just $ 500.71

The total amount of interest you will pay during that time is $500.71

Learn more about C++ click here:

https://brainly.com/question/28185875

#SPJ4


Related Questions

write a function named twowordsv2 that has the same specification as problem 1, but implement it using while and not using break. (hint: provide a dif

Answers

write a function named twowordsv2 that has the same specification as problem 1, but implement it using while and not using break.

Code in Python:

def twoWordsV2 (lgt,firstLr)

{

  w1 = ""

  w2= ""  

  while(len(w1)!=length)

  {

      word1 = input('A ' + str(lgt) + '-letter word here: ')

      }

  while(word2!=firstL):

    {

      word2 = input(' Word that begins with ' + firstL')

      if word2[0] == firstL.upper() or word2[0] == firstL.lower():

     {

          return [w1,w2]                

        }

print(twoWordsV2(4,'B'))

    }

}

What is a while loop? How does it work?

A while loop is a control flow statement that enables code to be performed repeatedly in most computer programming languages based on a specified Boolean condition. You can think of the while loop as an iterative if statement.

The while loop runs the code after first determining if the condition is true. Until the given condition returns false, the loop doesn't end. As an alternative, the do while loop only executes its code a second time if the condition is satisfied after the first execution.

To learn more about while loop, use the link given
https://brainly.com/question/19344465
#SPJ4

which cloud computing service model describes cloud-based systems that are delivered as a virtual solution for computing that allows firms to contract for utility computing as needed rather than build data centers?

Answers

Infrastructure as a Service is the concept that is cloud-based systems that is supplied as virtualized solution for computing that permits businesses to pay for utility computing instead of building data centers.

Describe data.

Data are a group of discrete values that describe amount, quality, fact, statistics, or other fundamental units of meaning, or they can simply be a series of symbols that can be further understood. A data is a specific value included in a group of data. The majority of the time, data is arranged into smaller structures, such tables, which give more context and meaning and can also be used as information in larger structures. It's possible to use data as variables in a calculation. Data can represent intangible concepts.

To know more about data
https://brainly.com/question/26711803
#SPJ1

whose name is attached to a type of computer architecture characterized by storing a program in the same place as regular data?

Answers

"Von Neumann" is the name attached to a type of computer architecture characterized by storing a program in the same place as regular data.

Explain Computer Architecture.

Computer architecture is a body of guidelines and techniques used in computer engineering to describe the operation, structure, and application of computer systems. The structure of a system is described in terms of its components, each of which is separately identified, and how they relate to one another.

Von Neumann architecture, still utilized by the majority of computer types today, is a very good example of computer architecture. The mathematician John von Neumann made this suggestion in 1945. It describes how the CPU of an electronic computer, which consists of an arithmetic logic unit, a control unit, registers, memory for data and instructions, an input/output interface, and external storage capabilities, is built.

To learn more about computer architecture, use the given link
https://brainly.com/question/20568202
#SPJ4

Other Questions
Rabbits are important grazers, maintaining some important grassland habitats. If another catastrophe were to reduce rabbit populations what would happen?. Seminole Company began the year with 23,000 units of product in its January 1 inventory costing $15 each. It made four purchases of its product during the year as follows. The company uses a periodic inventory system. On December 31, a physical count reveals that 40,000 units of its product remain in inventory. denise davenport thought her cat bit her today. she sees dr. dunbar as a precaution. dr. dunbar diagnoses denise with a cat bite to the right forearm. what codes are assigned? What do the graphs indicate about Bolivias labor force?Few people in Bolivia work in services.Few people in Bolivia work in industry.Most people in Bolivia work in agriculture.Most people in Bolivia work in industry. Glucose and fructose are both c6h12o6. What is the structural difference between them?. why is the columbian exchange named after christopher columbus? group of answer choices he invented the term he was an expert on central american species his ship was nicknamed the columbian exchange his voyages marked the exchange's beginning Logan's family drinks a total of 12 gallons of milk every 6 weeks. a. How many gallons of milk does the family drink per week? Solve for x with steps. Will mark brainliest. which statement would the nurse include when teaching a patient about the medication classification of triptans, of which a newly prescribed medication belongs? Economists that do not believe in market failures or that believe the government is not the appropriate entity to intervene when market failures occur, are _____. a company decides to motivate its salespeople by awarding a trip to hawaii to the salesperson who sells the most products over a two-month period. what type of motivational strategy is this? Dani Corporation ha 7 million hare of common tock outtanding. The current hare price i $73, and the book value per hare i $8. The company alo ha two bond iue outtanding. The firt bond iue ha a face value of $90 million, ha a coupon rate of 6 percent, and ell for 98 percent of par. The econd iue ha a face value of $75 million, ha a coupon rate of 5 percent, and ell for 110 percent of par. The firt iue mature in 22 year, the econd in 7 year. Suppoe the mot recent dividend wa $4. 45 and the dividend growth rate i 4. 8 percent. Aume that the overall cot of debt i the weighted average of that implied by the two outtanding debt iue. Both bond make emiannual payment. The tax rate i 24 percent. What i the company WACC? under neutral enso conditions, where over the equatorial pacific ocean would you expect to find relatively higher atmospheric pressure (subsidence)? 8-9. If AG = 2, GF = 5, FE = 3, GB = 6, CD = 7 and GB || FC || ED, find the lengths of the missing sides?AB=?BC=?FC=?ED=? Katalin drove 300 miles on her vacation. she drove an average of 1.9 times faster on the second 150 miles of her trip than she did on the first 150 miles of her trip. which expression represents the time she spent driving? {Question 19} Please help! Need by tonight! Thanks Which us president was known for his conservation policy for the environment and the creation of national parks?. Brain waves that are lowest in frequency and highest in amplitude are called _____________ waves. An individual that chooses to forego attraction in a relationship in lieuof financial stability would be an example of what theory? Which of the following is equal to 6.62