Syvum Home Page

Home > Discussions > For all activities

Discussion topic: Contributed Answer/Explanation to Q. 3

Viewing replies        View entire discussion

To go to the homepage of this topic, click here.
Home: freak7648Original MessageReply  
Subject: Contributed Answer/Explanation to Q. 1
   java class
   import java.io.*;
   class ques
   {
   public static void main(String args[])throws IOException
   {
   InputStreamReader read =new InputStreamReader(System.in);
   BufferedReader in =new BufferedReader(read);
   System.out.print("Month Number : ");
   int m=Integer.parseInt(in.readLine());
   System.out.println(); 
   System.out.print("Day : ");
   int c=Integer.parseInt(in.readLine());
   System.out.println();
   System.out.print("Year : ");
   int y=Integer.parseInt(in.readLine());
   System.out.println();
   int y1=y;
   int m1=m-1;
   int a[]={31,28,31,30,31,30,31,31,30,31,30,31};
   int b[]={31,29,31,30,31,30,31,31,30,31,30,31};
   int d=0,e;
   for (int j=0;j<m1;j++)
   {
   if (y1%4==0)
   {d=d+b[j];}
   else
   {d=d+a[j];}
   }
   int d1=d+c;
   System.out.print("Corresponding Day Of The Year Is : "+d1);
   System.out.println();
   System.out.print("(");
   for (int j=0;j<m1;j++)
   {
   if (y1%4==0)
   {e=b[j];
   System.out.print(e +"+");}
   else
   {e=a[j];
   System.out.print(e +"+");}
   }
   System.out.print(c+") ="+d1);
   System.out.println();
   }
   }

Posted at: Thu Feb 10 11:31:02 2011 (GMT)

Page 1 of 1
From: freak7648Reply 1 of 1Reply
Subject: decor
   the extra loops are to finally facilitate to the ques as demanded
   :)

Posted at: Thu Feb 10 11:31:57 2011 (GMT)

Page 1 of 1

To post to this forum, you must be signed in as a Syvum member. Please sign in / register as a member.

Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright