In: Computer Science
The late fee for a book at the Palm Beach State College library is accessed on a sliding scale depending upon how many days late the book is. For books less than 5 days late, the fee is 10 cents per day. If the book is late 5 through 20 days, the late fee is 25 cents a day, and if the book is more that 20 days late, the student must pay the full cost for the book. Write a program that prompts the user to enter the number of days late for a book and the book's purchase price. Based on the input, output what the fee will be for the late book.
This is C++ class. Thank you.
#include<iostream>
using namespace std;
class Book{
private:
int late_days;
float price;
float fee;
public:
void getInput(){
cout<<"Please
enter the number of late days :";
cin>>late_days;
cout<<"Please
enter the actual price of the book :";
cin>>price;
}
void calculateFee(){
if (late_days <5)
fee=10*late_days;
else if (late_days >= 5 && late_days
<= 20)
fee =
25*late_days;
else if (late_days > 20)
fee = price;
cout<<"Late Fee to be charged is :
"<<fee<<" Cents";
}
};
int main(){
Book
b;
//object creation
b.getInput();
//Function for taking inputs from user
b.calculateFee();
//Function for calculating fee
}