Sort by

recency

|

783 Discussions

|

  • + 0 comments

    ` C# CSharp

    static void Main(string[] args)
    {
        // Read and assign the returned and due dates
        DateTime returnedDate = AssignDate(Console.ReadLine());
        DateTime dueDate = AssignDate(Console.ReadLine());
    
        // Calculate and display the fine
        if (returnedDate <= dueDate)
        {
            Console.WriteLine(0); // No fine if returned on or before the due date
        }
        else
        {
            int fine = 0;
    
            if (returnedDate.Year > dueDate.Year)
            {
                // Fine is fixed at 10000 if the return is in a different year
                fine = 10000;
            }
            else if (returnedDate.Month > dueDate.Month)
            {
                // Fine for being late by months within the same year
                fine = 500 * (returnedDate.Month - dueDate.Month);
            }
            else if (returnedDate.Day > dueDate.Day)
            {
                // Fine for being late by days within the same month and year
                fine = 15 * (returnedDate.Day - dueDate.Day);
            }
    
            Console.WriteLine(fine);
        }
    }
    
    // Method to parse input and return a DateTime object
    public static DateTime AssignDate(string dateInput)
    {
        string[] dateSplit = dateInput.Split(' ');
        int day = Convert.ToInt32(dateSplit[0]);
        int month = Convert.ToInt32(dateSplit[1]);
        int year = Convert.ToInt32(dateSplit[2]);
    
        return new DateTime(year, month, day); // Construct and return the DateTime
    }
    
  • + 0 comments
    da, ma, ya = input().split(" ") #actual d, m, y
    de, me, ye = input().split(" ") #expected d, m, y
    
    dd, md, yd = int(da)-int(de), int(ma)-int(me), int(ya)-int(ye) #difference between actual and expected
    
    # funtion to calculate fine based on difference in d, m , y
    def calc_fine(d, m, y):
        if y > 0:
            return 10000
        elif y == 0:
            if m > 0:
                return 500 * m
            elif m == 0:
                if d > 0:
                    return 15 * d
    
        return 0
        
    print(calc_fine(dd, md, yd))
    
  • + 0 comments
    d1,m1,y1=list(map(int,input().split()))
    d2,m2,y2=list(map(int,input().split()))
    
    if y1>y2:
        print(10000)
    elif y1 == y2:
        if m1 > m2:
            print(500 * (m1 - m2))
        elif m1 == m2:
            if d1 > d2:
                print(15 * (d1 - d2)) 
            else:
                print(0) 
        else:
            print(0) 
    else:
        print(0)
    
  • + 0 comments
    import datetime
    
    def book_fee(due_date: datetime.date, return_date: datetime.date) -> int:
        if return_date < due_date:
            return 0
    
        if (return_date.month, return_date.year) == (due_date.month, due_date.year):
            return 15 * (return_date.day - due_date.day)
    
        if due_date.year == return_date.year:
            return 500 * (return_date.month - due_date.month)
    
        return 10000
    
    
    return_date = datetime.date(
        **dict(
            zip(["day", "month", "year"], [int(_) for _ in input().split(" ")])
        )
    )
    due_date = datetime.date(
        **dict(
            zip(["day", "month", "year"], [int(_) for _ in input().split(" ")])
        )
    )
    
    print(book_fee(due_date, return_date))
    
  • + 0 comments
    from datetime import datetime
    def fine(returned,due):
        if int(returned[2])<1000:
            returned[2] = returned[2].zfill(4)
        if int(due[2])<1000:
            due[2] = due[2].zfill(4)
        
        due = datetime.strptime(" ".join(due),"%d %m %Y").date()
        returned = datetime.strptime(" ".join(returned),"%d %m %Y").date()
        if returned > due:
           if returned.year > due.year:
               return 10000
           if returned.month > due.month:
    
               return 500*(returned.month - due.month)
           if returned.day > due.day:
               return 15 * (returned.day - due.day)
        else:
           return 0
           
    print(fine(input().split(" "),input().split(" ")))