Syvum Home Page

Home > Discussions > For all activities

Discussion topic: Contributed Answer/Explanation to Q. 12

Viewing messages

To go to the homepage of this topic, click here.
<<  <  Page 4 of 4
From: krutikaReply 61 of 73Reply
Subject: Contributed Answer/Explanation to Q. 27
   program
   
   class shapes
   
   
   {
   
   
   public void area1(int r)
   
   
   {
   
   
   double a=r*r*3.14;
   
   
   System.out.println("area of circle"+a);
   
   
   }
   
   
   public void area2(int l,int b)
   
   
   {
   
   
   int b=l*b;
   
   
   System.out.println("area of rectangle"+b);
   
   
   }
   
   
   public void area3(int s)
   
   
   {
   
   
   int c=4*s;
   
   
   System.out.println("area of square"+c);
   
   
   }}

Posted at: Tue Oct 26 14:35:42 2010 (GMT)

From: bharat03Reply 62 of 73Reply
Subject: Contributed Answer/Explanation to Q. 15
   break is used to force immediate termination of a loop.continue is used to
   continue running the loop but to stop processing the remainder code in its
   body for a particular iteration

Posted at: Thu Oct 28 08:19:21 2010 (GMT)

From: angel118Reply 63 of 73Reply
Subject: Contributed Answer/Explanation to Q. 31
   import java.io.*;

Posted at: Thu Dec 16 15:40:02 2010 (GMT)

From: angel118Reply 64 of 73Reply         View replies (2)
Subject: Contributed Answer/Explanation to Q. 31
   import java.io.*;

Posted at: Thu Dec 16 15:40:02 2010 (GMT)

From: angel118Reply 65 of 73Reply
Subject: Contributed Answer/Explanation to Q. 31
   the code is written in the explanation
   <p><span style="white-space: pre" class="Apple-tab-span">import
   java.io.*;</span></p><p>class
   SumOfNumbers</p><p>public static void main(String
   args[])</p><p>throws
   IOException</p><p>{</p><p><span
   style="white-space: pre" class="Apple-tab-span">	    
   </span>BufferedReader br=new BufferedReader(new
   InputStreamReader(System.in));</p><p><span
   style="white-space: pre" class="Apple-tab-span">	   </span>int
   num;</p><p><span style="white-space: pre"
   class="Apple-tab-span">	 </span>double
   sumNegative=0,sumPosEven=0,sumPosOdd=0;</p><p><span
   style="white-space: pre" class="Apple-tab-span">	   
   </span>do</p><p><span style="white-space: pre"
   class="Apple-tab-span">  </span>{</p><p><span
   style="white-space: pre" class="Apple-tab-span">		
   </span>System.out.println("Enter  the number:
   ");</p><p><span style="white-space: pre"
   class="Apple-tab-span">		   
   </span>num=Integer.parseInt(br.readLine());</p><p><span
   style="white-space: pre" class="Apple-tab-span">		     
   </span>if(num<0)</p><p><span style="white-space:
   pre" class="Apple-tab-span">			 
   </span>sumNegative+=num;</p><p><span
   style="white-space: pre" class="Apple-tab-span">		
   </span>else if(num%2==0  &&
   num>0)</p><p><span style="white-space: pre"
   class="Apple-tab-span">			 
   </span>SumPosEven+=num;</p><p><span style="white-space:
   pre" class="Apple-tab-span">	     
   </span>else</p><p><span style="white-space: pre"
   class="Apple-tab-span">			    
   </span>sumPosOdd+=num;</p><p>}while(num!=0);</p><
   p>System.out.println("Sum of negative integers:
   "+sumNegative);</p><p> </p><p
   style="margin-top: 0px; margin-bottom: 2px">System.out.println("Sum
   of positive even integers: "+sumPosEven);</p><div><p
   style="margin-top: 0px; margin-bottom: 2px">System.out.println("Sum
   of positive odd integers:
   "+sumPosOdd);</p></div><div>}</div><div>}
    </div>

Posted at: Thu Dec 16 15:45:09 2010 (GMT)

From: angel118Reply 66 of 73Reply
Subject: Contributed Answer/Explanation to Q. 31
   the code is written in the explanation
   <p><span style="white-space: pre" class="Apple-tab-span">import
   java.io.*;</span></p><p>class
   SumOfNumbers</p><p>{ </p><p>public static void
   main(String args[])</p><p>throws
   IOException</p><p>{</p><p><span
   style="white-space: pre" class="Apple-tab-span">
   </span>BufferedReader br=new BufferedReader(new
   InputStreamReader(System.in));</p><p><span
   style="white-space: pre" class="Apple-tab-span">	   </span>int
   num;</p><p><span style="white-space: pre"
   class="Apple-tab-span">	 </span>double
   sumNegative=0,sumPosEven=0,sumPosOdd=0;</p><p><span
   style="white-space: pre" class="Apple-tab-span">	   
   </span>do</p><p><span style="white-space: pre"
   class="Apple-tab-span">  </span>{</p><p><span
   style="white-space: pre" class="Apple-tab-span">		
   </span>System.out.println("Enter  the number:
   ");</p><p><span style="white-space: pre"
   class="Apple-tab-span">		   
   </span>num=Integer.parseInt(br.readLine());</p><p><span
   style="white-space: pre" class="Apple-tab-span">		     
   </span>if(num<0)</p><p><span style="white-space:
   pre" class="Apple-tab-span">			 
   </span>sumNegative+=num;</p><p><span
   style="white-space: pre" class="Apple-tab-span">		
   </span>else if(num%2==0  &&
   num>0)</p><p><span style="white-space: pre"
   class="Apple-tab-span">			 
   </span>SumPosEven+=num;</p><p><span style="white-space:
   pre" class="Apple-tab-span">	     
   </span>else</p><p><span style="white-space: pre"
   class="Apple-tab-span">			    
   </span>sumPosOdd+=num;</p><p>}while(num!=0);</p><
   p>System.out.println("Sum of negative integers:
   "+sumNegative);</p><p style="margin-top: 0px; margin-bottom:
   2px">System.out.println("Sum of positive even integers:
   "+sumPosEven);</p><div><p style="margin-top: 0px;
   margin-bottom: 2px">System.out.println("Sum of positive odd
   integers:
   "+sumPosOdd);</p></div><div>}</div><div>}
    </div> 

Posted at: Thu Dec 16 15:45:35 2010 (GMT)

From: akhila49Reply 67 of 73Reply
Subject: Contributed Answer/Explanation to Q. 30
   the answer is done in explanation
   
   class ascending
   
   
   {
   
   
   int a{5,3,8,4,9,2,1,12,98,16};
   
   
   int len;
   
   
   ascending()
   
   
   {
   
   
   len=0;
   
   
   }
   
   
   public void main()
   
   
   {
   
   
   len=a.length;
   
   
   for(i=0;i<len;i++)
   
   
   {
   
   
   for(j=0;j<len;j++)
   
   
   {
   
   
   if(a[i]>a[j])
   
   
   {
   
   
   a[i]=a[j];
   
   
   a[j]=temp;
   
   
   temp=a[i];
   
   
   }
   
   
   }
   
   
   }
   
   
   }
   
   
   public void main1()
   
   
   {
   
   
   for(int i;i<len;i++)
   
   
   {
   
   
   System.out.println(a[i]);
   
   
   }
   
   
   }
   
   
   }

Posted at: Thu Jan 20 15:05:47 2011 (GMT)

From: rakchi_2011Reply 68 of 73Reply         View replies (1)
Subject: Contributed Answer/Explanation to Q. 11
   A default statement is a statement which gets executed when none of the
   choices are true in the switch statement.
   A default statement is a statement which gets executed when none of the
   choices in switch is true.

Posted at: Sat Jan 29 17:56:46 2011 (GMT)

From: rakchi_2011Reply 69 of 73Reply
Subject: Contributed Answer/Explanation to Q. 11
   A default statement is a statement which gets executed when none of the
   choices are true in the switch statement.

Posted at: Sat Jan 29 17:56:55 2011 (GMT)

From: hayabusaReply 70 of 73Reply
Subject: Contributed Answer/Explanation to Q. 31
   program
   class sum{public static void main(int n)int
   even=0,odd=0,neg=0; { while(n!=0){if(n>0&&n%2==0)even=even+n;if
   (n>0&&n%2!=0)odd=odd+n;if(n<0)neg=neg+n; } System.out.printl
   n("sum of positive even
   numbers="+even);System.out.println("sum of positive odd
   numbers="+odd);System.out.println("sum of negative
   numbers="+neg); } } 

Posted at: Mon Jan 31 14:44:57 2011 (GMT)

From: lokeshcReply 71 of 73Reply         View replies (2)
Subject: Contributed Answer/Explanation to Q. 32
   ANSWER 
   
   class name 

Posted at: Sun Feb 13 02:02:39 2011 (GMT)

From: lokeshcReply 72 of 73Reply
Subject: Contributed Answer/Explanation to Q. 32
   ANSWER 
   
   class name
   
   
   {
   
   
   public void search(String a)

Posted at: Sun Feb 13 02:05:41 2011 (GMT)

From: lokeshcReply 73 of 73Reply
Subject: Contributed Answer/Explanation to Q. 32
   ANSWER 
   
   class name
   
   
   {
   
   
   public void search(String a)
   
   
   {
   
   
   int e; 
   
   
   String c[] = {"Ab
   ","Cd","Ef","Gh","Ij"};
   
   
   String b[] =
   {"12","45","90","87","76"}
   ;
   
   
   for( e=0;e<5;e++)
   
   
   {
   
   
   if(a.equals(c[e]))
   
   
   {
   
   
   System.out.println("Search Successful");
   
   
   System.out.println(c[e]+" "+b[e]);
   
   
   else
   
   
   System.out.println("Seach unsuccessful.Name not enlisted.");
   
   
   }
   
   
   }
   
   
   } 

Posted at: Sun Feb 13 02:11:17 2011 (GMT)

<<  <  Page 4 of 4

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