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

interest = principal * rate * term / 365; The preceding formula assumes that rat

ID: 3814370 • Letter: I

Question

interest = principal * rate * term / 365;

The preceding formula assumes that rate is the annual interest rate, and therefore includes the division by 365 (days).

Develop a program that will input principal, rate and days for several loans, and will calculate and display the simple interest for each loan, using the preceding formula.

Use the below program template to answer each question. The program is created by answering all the questions hence, do not skip any question.

Using the Xendesktop, open Visual Studio 2015. Create a new project and add a new .cpp file to the project. Type the programming shell template as stated up above and continue with the following steps below. Be sure to include comments throughout your program for readability purposes.

(Housekeeping): Declare the following variables in your program using appropriate data type. When selecting a data type keep in mind the type of value you want to store, i.e., int, float, character. Also, be sure to use conventional naming standards for all variable declarations.

principal

rate

term

interest

(Output): Add a prompt to guide the user to input loan principal as a dollar amount. Take notice of the value restriction at the end of this output statement.

(Input): Add a scanf() statement to store user input for loan principal value.

(Control Structure): Add a looping statement that will keep on calculating interest charges until the user enters the value -1 as the principal value to end the process.

(Output): Add a prompt to guide the user to input interest rate as a decimal value.

(Input): Add a scanf() statement to store user input for rate value.

(Output): Add a prompt to guide the user to input length of the loan in days (term).

(Input): Add a scanf() statement to store user input for the number of days (term).

(Assignment Statement): Use the following equation for interest charge calculation.

interest = principal * rate * term / 365;

End looping structure and then create a prompt and input statement to ask the user for the next loan principal value.

Be sure to include comments throughout your program for readability purposes.

(Output Screen) After you compile your program successfully using Debug > Start without Debugging your output screen should look similar after entering in the values and using the value of -1 to end the program to the one below.

Explanation / Answer


// C++ code
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <limits.h>
#include <sstream>
#include <stdio.h>

using namespace std;


int main()
{
int principal,term,i=0;
float interest,rate;
cout << " Enter prinicipal amounts in dollars for different loans. Enter -1 at the end of the loans ";
//prompt to guide the user to input loan principal as a dollar amount
cout << "Enter loan principal amount in dollar($) value:";
//scanf() statement to store user input for loan principal value.
cin >> principal;
//looping structure to enter multiple loan details
do
{
//prompt to guide the user to input interest rate as a decimal value.
cout << "Enter the interest rate in decimal value:";
//scanf() statement to store user input for rate value.
cin >> rate;
//prompt to guide the user to input length of the loan in days (term).
cout << "Enter the length of the loan in days (term):";
//scanf() statement to store user input for the number of days (term)
cin >> term;
//calculate interest charge
interest = principal * rate * term / 365;
//display the intereset value
cout << "Interest calculated is "<< interest << endl;
//prompt for user to enter the next loan principal value
cout << "Enter next loan principal amount:";
cin >> principal;
}while(principal!= -1);
return 0;
}


/*
output:

Enter prinicipal amounts in dollars for different loans. Enter -1 at the end of the loans
Enter loan principal amount in dollar($) value:37838
Enter the interest rate in decimal value:0.06
Enter the length of the loan in days (term):9292
Interest calculated is 57795.730469
Enter next loan principal amount:3939
Enter the interest rate in decimal value:0.05
Enter the length of the loan in days (term):8282
Interest calculated is 4468.876465
Enter next loan principal amount:-1


*/