Library Fines ,this program was created to solve Library Fines problem.
The fee structure is as follows:
- If the book is returned on before 5 days, no fine will be charged.
- If the book is returned after the expected return day (between 5 and 10 days) – fine: 0.5$ per day
- If the book is returned after the expected return day (between 10 and 30 days) fine: 1$ per day
- If the book is not returned after 30 days, cancel membership. fine: 1.5$ per day
Form Design:
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace calculate_library_fine { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.Text = "csharp-console-examples.com"; this.BackColor = Color.Orange; } private void button1_Click(object sender, EventArgs e) { int days; float fine = 0; days = Convert.ToInt32(textBox1.Text); if (days <= 5) { fine = 0; label2.Text = "Your fine:" + fine + " $"; } else if (days > 5 && days <= 10) { fine = (days - 5) * 0.5F; label2.Text = "Your fine:" + fine + " $"; } else if (days > 10 && days <= 30) { // ----5 days--- --between 10 and 30--- fine = 5 * 0.5F + (days - 10) * 1; label2.Text = "Your fine:" + fine + " $"; } else { // -5 days- -10 , 30- - >30 - fine = 5 * 0.5F + 20 * 1 + (days - 30) * 1.5F; label2.Text= "Canceled your Membership.\nYour fine:" + fine + " $"; } } } } |
Output: