Hw Assignemnt 2

Unformatted Attachment Preview

Problem 1:- (12 Points)
Write a C++ program that accepts an amount of money on deposit and a number of
years it has been on deposit (years can have decimals). It will determine the interest to
be paid on the deposit based on the following schedule:
Time on Deposit
Interest Rate
>= 5 years
4.5%
Less than 5 and >=4 years
4%
Less than 4 and >=3 years
3.5%
Less than 3 and >=2 years
2.5%
Less than 2 and >=1 years
2%
Less than 1 year
1.5%
Compute the interest with the formula: Interest = Deposit * IntRate * Years.
Display the original deposit, the interest earned and the new Balance (with interest
added to the deposit.
#include
using namespace std;
int main() {
double deposit, years, interestRate, interest, newBalance;
// Accept input from the user
cout > deposit;
cout > years;
// Determine the interest rate based on the number of years
if (years >= 5) {
interestRate = 4.5;
} else if (years >= 4) {
interestRate = 4.0;
} else if (years >= 3) {
interestRate = 3.5;
} else if (years >= 2) {
interestRate = 2.5;
} else if (years >= 1) {
interestRate = 2.0;
} else {
interestRate = 1.5;
}
// Calculate the interest
interest = deposit * (interestRate / 100) * years;
// Calculate the new balance
newBalance = deposit + interest;
// Display the results
cout …
Purchase document to see full attachment

Don't use plagiarized sources. Get Your Custom Assignment on
Hw Assignemnt 2
From as Little as $13/Page