Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# Programming: Create an application for a library and name it FineForOverdueBo

ID: 3737936 • Letter: C

Question

C# Programming:

Create an application for a library and name it FineForOverdueBooks. TheMain() method asks the user to input the number of books checked out and the number of days they are overdue. Pass those values to a method named DisplayFine that displays the library fine, which is 10 cents per book per day for the first seven days a book is overdue, then 20 cents per book per day for each additional day.

The library fine should be displayed in the following format:

This coding below is my attempt and is incorrect.

+FineForoverdueBooks.cs Instructions 1 using System; 2 using static System.Console; 3 public class FineForOverdueBooks 4 5public static void Main() Create an application for a library and name it FineForOverdueBooks. The Main() method asks the user to input the number of books checked out and the number of days they are overdue. Pass those values to a method named DisplayFine that displays the library fine, which is 10 cents per book per day for the first seven days a book is overdue, then 20 cents per book per day for each additional day 7/ Write your main here. 9 public static void DisplayFine(int books, int days) 10 11 / Write your DisplayFine method here. 12 13 fine should be displayed in The library the following format: The fine for 2 book(s) for 3 day(s) (The numbers will vary based on the input.)

Explanation / Answer

using System.IO;
using System;

class FineForOverdueBooks
{
static void Main()
{
Console.WriteLine("Enter the number of books user checked out: ");
int books = Convert. ToInt32(Console.ReadLine());

Console.WriteLine("Enter the number of overdue days: ");
int days = Convert. ToInt32(Console.ReadLine());

DisplayFine(books, days);
}
public static void DisplayFine(int books, int days) {
double amt = 0;
int d = days;
if(days>7) {
amt = (days-7) * .20 * books;
days = 7;
}
if(days > 0) {
amt = amt + days * .10 * books;
}
Console.WriteLine("The fine for {0} book(s) for {1} day(s) is {2}", books, d, amt);
}
}

Output:

Enter the number of books user checked out: 5
Enter the number of overdue days: 10
The fine for 5 book(s) for 10 day(s) is 6.5