NY Regents Exam   Teasers   IQ Tests   Chemistry   Biology   GK   C++   Recipes   Search <  a href="/cgi/members/home.cgi" class="toplink">Members   Sign off

## Discussion topic: Contributed Answer/Explanation to Q. 3

#### Viewing messages

 Page 1 of 1 From: akash5 Reply 1 of 10 Reply Subject: Contributed Answer/Explanation to Q. 3 ``` java import java.io.*;
class exam2001
{    public static void main (String args[]) throws IOException
{   int s[]=new int [5];
int a[]=new int [5];
int c[]=new int [11];
int i,l,j;//for s
int I,L,J; //for a
DataInputStream in = new DataInputStream (System.in);
System.out.println("s[i] :");
for ( i=0;i<=4;i++)
{   System.out.print ("no.  ");
}
System.out.println("a[i] :");
for ( I=0;I<=4;I++)
{   System.out.print ("no.  ");
}
for ( i=0;i<5;i++)
{for ( j=0;j<5-i-1;j++)
{if (s[j]>s[j+1])
{   l=s[j];
s[j]=s[j+1];
s[j+1]=l;
}}  }
for ( I=0;I<5;I++)
{ for ( J=0;J<5-I-1;J++)
{ if (a[J]>a[J+1])
{   L=a[J];
a[J]=a[J+1];
a[J+1]=L;
} }}
System.out.println("s[i] :");
for ( i=0;i<=4;i++)
{ System.out.println(s[i]);}

System.out.println("a[I] :");
for ( I=0;I<=4;I++)
{System.out.println(a[I]); }

int x,y;
// to merge n sort array s & a in c.....
for(x=0,i=0,I=0;x<10;x++)
{ if(s[i]              { c[x]=s[i];
i++;
if(i>=5)
{ for(x++;I<5;I++,x++)
c[x]=a[I];           }  }
else
{      c[x]=a[I];
I++;
if(I>=5)
{ for(x++;i<5;i++,x++)
c[x]=s[i];
}    }   }
System.out.println("The c[x] is : ");
for(x=0;x<20;x++)
{  System.out.println(c[x]);}}}    ```Posted at: Thu Jan 28 06:27:46 2010 (GMT) From: asha_g_mca Reply 2 of 10 Reply View replies (1) Subject: Contributed Answer/Explanation to Q. 1 ``` JAVA class lucky  {  int arr[ ]; public static void display(int q, int n) {int size=n/q;   int b[ ]= new int[size]; for(int i=0,j=0;jn ) {        flag=false;        break;             } } } else System.out.println("Enter a number less than 50"); } }   ```Posted at: Tue Sep 14 06:56:34 2010 (GMT) From: asha_g_mca Reply 3 of 10 Reply Subject: Contributed Answer/Explanation to Q. 1 ``` JAVA class lucky  {  int arr[ ]; public static void display(int q, int n) {int size=n/q;   int b[ ]= new int[size]; for(int i=0,j=0;j  System.out.println("Removing every" +q +"number we get:");  for(int i=0;i<=b.length;i+=q)  System.out.print(b[i]+"    "); System.out.println(); } public static void main(int n) { if (n<50) {  int q=1; for(int i=0;in ) {        flag=false;        break;             } } } else System.out.println("Enter a number less than 50"); } }   ```Posted at: Tue Sep 14 06:57:57 2010 (GMT) From: prerit_agarwal Reply 4 of 10 Reply Subject: Contributed Answer/Explanation to Q. 1 ``` the easier way........     class isc2001     {         public static void main(int n)         {             int i,j=0;             int a[]=new int[n];             int b[]=new int[n/2];             for(i=0;i Use can understand this by just looking

```Posted at: Mon Feb 17 08:05:22 2014 (GMT) From: samprithi Reply 10 of 10 Reply Subject: Contributed Answer/Explanation to Q. 2 ```  import java.io.*; public class year {     BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); public void show()throws IOException { int month; System.out.println("Enter the month"); int m=Integer.parseInt(br.readLine());     System.out.println("Enter the day"); int d=Integer.parseInt(br.readLine()); System.out.println("Enter the year"); int y=Integer.parseInt(br.readLine()); if(y%4==0) { switch(m)   {  case 01:  month=d;  System.out.println("number of days"+month);  break; case 02: month=31+d; System.out.println("number of days"+month); break; case 03: month=31+29+d; System.out.println("number of days"+month); break; case 04: month=31+29+31+d; System.out.println("number of days"+month); break; case 05: month=31+29+31+30+d; System.out.println("number of days"+month); break; case 06: month=31+29+31+30+31+d; System.out.println("number of days"+month); break; case 07: month=31+29+31+30+31+30+d; System.out.println("number of days"+month); break; case 8: month=31+29+31+30+31+30+31+d; System.out.println("number of days"+month); break; case 9: month=31+29+31+30+31+30+31+d+31; System.out.println("number of days"+month); break; case 10: month=31+29+31+30+31+30+31+d+31+30; System.out.println("number of days"+month); break; case 11: month=31+29+31+30+31+30+31+d+31+30+31; System.out.println("number of days"+month); break; case 12: month=31+29+31+30+31+30+31+d+31+30+31+30; System.out.println("number of days"+month); break; default : System.out.println("error"); break; }} else   { switch(m) { case 01: month=d; System.out.println("number of days"+month); break; case 02: month=31+d; System.out.println("number of days"+month); break; case 03: month=31+28+d; System.out.println("number of days"+month); break; case 04: month=31+28+31+d; System.out.println("number of days"+month); break; case 05: month=31+28+31+30+d; System.out.println("number of days"+month); break; case 06: month=31+28+31+30+31+d; System.out.println("number of days"+month); break; case 07: month=31+28+31+30+31+30+d; System.out.println("number of days"+month); break; case 8: month=31+28+31+30+31+30+31+d; System.out.println("number of days"+month); break; case 9: month=31+28+31+30+31+30+31+d+31; System.out.println("number of days"+month); break; case 10: month=31+28+31+30+31+30+31+d+31+30; System.out.println("number of days"+month); break; case 11: month=31+28+31+30+31+30+31+d+31+30+31; System.out.println("number of days"+month); break; case 12: month=31+28+31+30+31+30+31+d+31+30+31+30; System.out.println("number of days"+month); break; default : System.out.println("error"); break; }}   }} ```Posted at: Sat Feb 7 08:30:09 2015 (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.