We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 26: Nested Logic
  5. Discussions

Day 26: Nested Logic

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

    You are viewing a single comment's thread. Return to all comments →

  • e_ozbey01
    3 months ago+ 0 comments

    My Soluton for Java;

    public static void main(String[] args) {

        Scanner in= new Scanner(System.in);
        int[] arr= new int[6];
        for(int i=0; i<6;i++)
        {
            arr[i]= in.nextInt();
        }
        int fine=0;
        int actualrday=arr[0];
        int actualrmonth=arr[1];
        int actualryear=arr[2];
        int expectedrday=arr[3];
        int expectedrmonth=arr[4];
        int expectedyear=arr[5];
        in.close();
    
    
        if(actualryear==expectedyear)
        {
            if(actualrmonth<=expectedrmonth){
                if(actualrday<=expectedrday)
                {
                    fine=0;
                }
                else{fine=(actualrday-expectedrday)*15;}
            }
            else{fine=(actualrmonth-expectedrmonth)*500;}    
        }
        else if(actualryear<expectedyear)
        {
            fine=0;
        }
        else if(actualryear>expectedyear){fine=10000;}
    
        System.out.println(fine);
    }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy