The first question: Write a program to implement the algorithm that you designed in Exercise 19 of Chapter 1. Your program should allow the user to buy as many items as the user desires. Instructions for Exercise 19 of Chapter 1 have been posted below for your convenience. Exercise 19 Jason typically uses the Internet to buy various items. If the total cost of the items ordered, at one time, is $200 or more, then the shipping and handling is free; otherwise, the shipping and handling is $10 per item. Design an algorithm that prompts Jason to enter the number of items ordered and the price of each item. The algorithm then outputs the total shipping and handling fee, and the billing amount. Your algorithm must use a loop (repetition structure) to get the price of each item. (For simplicity, you may assume that Jason orders no more than five items at a time.)   #include  using namespace std; int main() {   float n, temp,totalPrize = 0;   cout << "Enter the number of items ordered: ";   cin >> n; }   for (int i=1; i<=n; ++i) {   cout << "Enter the price of item no." << i << ":";   cin >> temp;      totalPrize = totalPrize + temp; } if (totalPrize >= 200) {   cout << "The shipping and handling fee is: $0.00" << endl;   cout << "The billing amount is: $" << totalPrize << endl; } else {   float shippingAndHandingFee = n * 10;   totalPrize = totalPrize + shippingAndHandingFee;      cout << "The shipping and handling fee is: $" << shippingAndHandingFee << endl;   cout << "The billing amount is: $" << totalPrize + n << endl; }          return 0; }   The second question: Summary When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first month’s interest on $1,000 is 1000 X 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 - 6 = 19. This means after making the first payment, the loan amount is 1,000 - 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 X 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 - 5.89 = 19.11 and the remaining balance after the second payment is 981 - 19.11 = 961.89. This process is repeated until the loan is paid. Instructions Write a program that accepts as input: The loan amount The interest rate per year The monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first month’s interest, then after each payment, the loan amount will increase.) In this case, the program must warn the borrower that the Monthly payment is too low. The loan cannot be repaid.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

The first question:

Write a program to implement the algorithm that you designed in Exercise 19 of Chapter 1.

Your program should allow the user to buy as many items as the user desires.

Instructions for Exercise 19 of Chapter 1 have been posted below for your convenience.

Exercise 19

Jason typically uses the Internet to buy various items. If the total cost of the items ordered, at one time, is $200 or more, then the shipping and handling is free; otherwise, the shipping and handling is $10 per item. Design an algorithm that prompts Jason to enter the number of items ordered and the price of each item. The algorithm then outputs the total shipping and handling fee, and the billing amount. Your algorithm must use a loop (repetition structure) to get the price of each item. (For simplicity, you may assume that Jason orders no more than five items at a time.)

 
#include <iostream>
using namespace std;
int main()
{
  float n, temp,totalPrize = 0;
  cout << "Enter the number of items ordered: ";
  cin >> n;
}
  for (int i=1; i<=n; ++i)
{
  cout << "Enter the price of item no." << i << ":";
  cin >> temp;
  
  totalPrize = totalPrize + temp;
}
if (totalPrize >= 200)
{
  cout << "The shipping and handling fee is: $0.00" << endl;
  cout << "The billing amount is: $" << totalPrize << endl;
}
else
{
  float shippingAndHandingFee = n * 10;
  totalPrize = totalPrize + shippingAndHandingFee;
  
  cout << "The shipping and handling fee is: $" << shippingAndHandingFee << endl;
  cout << "The billing amount is: $" << totalPrize + n << endl;
}
    
    return 0;
}
 
The second question:

Summary

When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time.

Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount.

To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first month’s interest on $1,000 is 1000 X 0.006 = 6.

Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 - 6 = 19. This means after making the first payment, the loan amount is 1,000 - 19 = 981.

For the second payment, the interest is calculated on $981. So the interest for the second month is 981 X 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 - 5.89 = 19.11 and the remaining balance after the second payment is 981 - 19.11 = 961.89. This process is repeated until the loan is paid.

Instructions

Write a program that accepts as input:

  1. The loan amount
  2. The interest rate per year
  3. The monthly payment.

(Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.)

The program then outputs the number of months it would take to repay the loan.

(Note that if the monthly payment is less than the first month’s interest, then after each payment, the loan amount will increase.)

In this case, the program must warn the borrower that the Monthly payment is too low. The loan cannot be repaid.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT