Friday, 22 January 2021

program of class 11th to take date/month/year and ceck the date is valid or not if valid then print the number of days

import java.io.*;
class valid
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("entre the date");
        int d=Integer.parseInt(br.readLine());
        System.out.println("entre month");
        String s=br.readLine();
        System.out.println("entre year");
        int y=Integer.parseInt(br.readLine());
        int t=0;
        String month[]={"january","february","march","aprai","may","june","july","august","september","october","november","december"};        
        int year[]={31,28,31,30,31,30,31,31,30,31,30,31};
        if(y%4==0)
        {
            year[1]=29;
        }for(int i=0;i<12;i++)
           {
               if(s.equalsIgnoreCase(month[i]))
               {
                   t=i;
                }
            }
        if(d<=year[t])
        {
           for(int i=0;i<12;i++)
           {
               if(s.equalsIgnoreCase(month[i]))
               {
                   t=i;
                }
            }
            for(int i=0;i<t;i++)
            {
                d=d+year[i];
            }
            System.out.println(d+"days"+y);
        }
        else
        System.out.println("invalid date");
    }
}
    
          

No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...