Sort by

recency

|

39 Discussions

|

  • + 0 comments
            int fine=0;
    
                if(returned_y<due_y){
                    fine = 0; 
                } else if(returned_y>due_y){
                    fine = 10000;
                } else if(returned_m>due_m){
                        fine = (returned_m-due_m)*500;
                } else if(returned_d>due_d){
                        fine = (returned_d-due_d)*15;
                }
            System.out.println(fine);
    
  • + 0 comments

    Constant time procedure using Java:

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Queue <Integer> myQueue = new LinkedList<Integer>();
    
        for (int i = 0; i < 3; i++) {
            myQueue.add(input.nextInt());
        }
    
        int dif1 = myQueue.remove() - input.nextInt();
        int dif2 = myQueue.remove() - input.nextInt();
        int dif3 = myQueue.remove() - input.nextInt();
    
        if ((dif1 <= 0 && dif2 <= 0 && dif3 <= 0) || (dif1 > 0 && (dif2 < 0 || dif3 < 0)))
            System.out.println(0);
        else if (dif1 > 0 && dif2 == 0 && dif3 == 0) 
            System.out.println(15*dif1);
        else if (dif2 > 0 && dif3 == 0) 
            System.out.println(500*dif2);
        else 
            System.out.println(10000);
    
    }
    
  • + 0 comments

    C++ code

    #include <cmath>
    #include <cstdio>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    
    int main() {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
        int D,M,Y,d,m,y,fine=0;
        cin>>D>>M>>Y;
        cin>>d>>m>>y;
        if(D>d&&M==m&&y==Y)
            fine=15*(D-d);
        else if(M>m&&y==Y)
            fine=500*(M-m);
        else if(Y>y)
            fine=10000;
        
        cout<<fine;
        
        
        return 0;
    }
    
  • + 0 comments

    you dont need anything else than some nested if n else.

    date,month,year = map(int,input().strip().split())
    DueDate,DueMonth,DueYear = map(int,input().strip().split())
    
    DayLate = date-DueDate
    monthLate = month-DueMonth
    yearLate = year-DueYear
    
    if yearLate==0:
        if monthLate==0:
            if DayLate<=0:
                print(0)
            else:
                print(DayLate*15)
        elif monthLate < 0 :
            print(0)
        else:
            print(500*monthLate)
    elif yearLate < 0:
        print(0)
    else:
        print(10000)
    
  • + 0 comments

    The test case #6 has inputs: 8 4 12 1 1 1 and the expected output is: 10000

    but the difference between the years is 12-1 = 11 and the fine will be: fine = 11 * 10000 = 110000

    this test case itself is wrong