85.3k views
2 votes
Need help how to type the code please

Need help how to type the code please-example-1

1 Answer

0 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 Marvin Emil Brach
by
8.3k points

No related questions found