Answer to Question #205897 in C++ for Zaza

Question #205897

Create a program for a library whose Main() method asks the user to input the number of books checked out and the number of days they are overdue. Pass those values to a method that calculates and displays the library fine, which is 20 cents per book per day for the first seven days a book is overdue, then 50 cents per book per day for each additional day.


1
Expert's answer
2021-06-11T17:02:59-0400
#unclude <iostream>

int main()
{
  std::cout << "Library program.." << std::endl;
  int books, days;
  std::cout << "Input number of books: ";
  std::cin >> books;
  std::cout << "Input number of days: ";
  std::cin >> days;
  double price = 0;
  for (int i = 1; i <= days; i++)
    if (days <= 7)
      price += 0.2 * books;
    else
      price += 0.5 * books;
  std::cout << "Total: " << price << std::endl;
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog