EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

 

Here’s a simple Java program that accepts the  number of late days and calculates the fine or displays the membership cancellation message:

import java.util.Scanner;

 

public class LibraryFine {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

 

// Input number of late days

System.out.print(“Enter number of days late: “);

int daysLate = sc.nextInt();

 

if (daysLate <= 0) {

System.out.println(“No fine. Book returned on time.”);

} else if (daysLate <= 5) {

System.out.println(“Fine is ₹5”);

} else if (daysLate <= 10) {

System.out.println(“Fine is ₹10”);

} else if (daysLate <= 30) {

System.out.println(“Fine is ₹50”);

} else {

System.out.println(“Membership cancelled due to delay over 30 days.”);

}

}

}

📌 Sample Runs:

Input: 3

Output: Fine is ₹5

 

Input: 12

Output: Fine is ₹50

 

Input: 35

Output: Membership cancelled due to delay over 30 days.

 

 

Java simple program for practice

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer