1. Remembering the rules of precedence and associativity write the calue of the
ID: 3628841 • Letter: 1
Question
1. Remembering the rules of precedence and associativity write the calue of the following arithmetic expressions or error if an error would occur:
a. 4 + 8 * 2
b. 6 + 17 % 3 / 2
c. (16 + 7) % 2 - 1
d. 4 / 8 * 2
e. 2.7 * 6.2 % 6
2. Write a program that will allow someone to calculate their monthly payment for a car loan. the program must allow a user to enter (cin) the following values;
total amount of loan (LoanAmount)
Interest rate (Rate)
Number of months (NumberMonths)
you should calculate the monthly payment according to the following formula:
for example for a loan amount of 1800 an interest rate of 4.9% and 60 months the payment should be 338.86
your second PHP page will need to use the built in pow() function
the Rate used in the formula ablve should be the interest rate expressed as a decimal ie 0.049
a person filling in the form can be expected to just enter numbers in the text boxes no symbols .
format your payment amount to two deciamal places.
Explanation / Answer
please rate - thanks
1. Remembering the rules of precedence and associativity write the calue of the following arithmetic expressions or error if an error would occur:
a. 4 + 8 * 2 20
b. 6 + 17 % 3 / 2 7
c. (16 + 7) % 2 - 1 0
d. 4 / 8 * 2 1
e. 2.7 * 6.2 % 6 error
your example is wrong, amount should read 18000 and formula is wrong
#include <iostream>
#include <cmath>
using namespace std;
int main()
{ double rate,loan,payment,term;
int months;
cout<<"How much is the loan for? ";
cin>>loan;
cout<<"What is the interest rate (as a % ie: 5.2)? ";
cin>>rate;
rate=rate/100.;
cout<<"How many months is the loan for ";
cin>>months;
payment=(loan*(rate/12.))/(1-pow((1+rate/12),(months*-1)));
cout<<"Your monthly payment is: "<<payment<<endl;
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.