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.
#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;
}
Comments
Leave a comment