44,235 views
30 votes
30 votes
Need help how to type the code please

Need help how to type the code please-example-1
User Evan Byrne
by
3.1k points

1 Answer

20 votes
20 votes

Answer:

#include <stdio.h>

#define MAXIMUM_LOAN_PERIOD 14

#define FINE_RATE 0.20

#define SEPARATOR "----------------"

int main() {

double amountFined;

int numberOfBooks, daysLoan, daysOverdue;

printf(SEPARATOR "\\BOOK LOAN SYSTEM\\" SEPARATOR "\\");

printf("Enter the number of books : ");

scanf("%d", &numberOfBooks);

printf("Enter the days of the loan : ");

scanf("%d", &daysLoan);

printf(SEPARATOR SEPARATOR SEPARATOR "\\");

daysOverdue = daysLoan - MAXIMUM_LOAN_PERIOD;

amountFined = FINE_RATE * numberOfBooks * daysOverdue;

printf("Days overdue : %d\\", daysOverdue);

printf("Fine : RM %.2f\\", amountFined);

return 0;

}

Step-by-step explanation:

Reading integers can be done using scanf. What is missing in this code is checking for bad input, but the happy flow works!

User Rentrop
by
2.7k points