<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>electrofriends.com &#187; Java</title>
	<atom:link href="http://electrofriends.com/category/source-codes/software-programs/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://electrofriends.com</link>
	<description>...bringing innovative minds together</description>
	<lastBuildDate>Fri, 11 May 2012 08:44:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Java program to print Fibonacci sequence Recursive &amp; Non Recursive</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-print-fibonacci-sequence-recursive-recursive/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-print-fibonacci-sequence-recursive-recursive/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 10:44:27 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[fibonacci]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[non-recursive]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1367</guid>
		<description><![CDATA[The Fibonacci sequence is defined by the following rule. The first 2 values in the sequence are 1, 1. Every subsequent value is the sum of the 2 values preceding it. Write a Java program that uses both recursive and non-recursive functions to print the nth value of the Fibonacci sequence. 1 2 3 4 [...]]]></description>
			<content:encoded><![CDATA[<p>The Fibonacci sequence is defined by the following rule. The first 2 values in the sequence are 1, 1. Every subsequent value is the sum of the 2 values preceding it. Write a Java program that uses both recursive and non-recursive functions to print<br />
the nth value of the Fibonacci sequence.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*Non Recursive Solution*/</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Scanner</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Fib <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Scanner input<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> Scanner<span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> i,a<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>,b<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>,c<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,t<span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Enter value of t:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		t<span style="color: #339933;">=</span>input.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">+</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>t<span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			c<span style="color: #339933;">=</span>a<span style="color: #339933;">+</span>b<span style="color: #339933;">;</span>
			a<span style="color: #339933;">=</span>b<span style="color: #339933;">;</span>
			b<span style="color: #339933;">=</span>c<span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">+</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>t<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;th value of the series is: &quot;</span><span style="color: #339933;">+</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* Recursive Solution*/</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Demo <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">int</span> fib<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">==</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>fib<span style="color: #009900;">&#40;</span>n<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>fib<span style="color: #009900;">&#40;</span>n<span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">class</span> RecFibDemo <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">InputStreamReader</span> obj<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedReader</span> br<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;enter last number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> n<span style="color: #339933;">=</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>br.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Demo ob<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> Demo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;fibonacci series is as follows&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> res<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;=</span>n<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			res<span style="color: #339933;">=</span>ob.<span style="color: #006633;">fib</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">+</span>res<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;th value of the series is &quot;</span><span style="color: #339933;">+</span>res<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-print-fibonacci-sequence-recursive-recursive/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Java program to prints all real solutions to the quadratic equation ax2+bx+c = 0</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-prints-real-solutions-quadratic-equation-ax2bxc-0/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-prints-real-solutions-quadratic-equation-ax2bxc-0/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 10:42:09 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[quadratic equation]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1365</guid>
		<description><![CDATA[Write a Java program that prints all real solutions to the quadratic equation ax2+bx+c = 0. Read in a, b, c and use the quadratic formula. If the discriminant b2-4ac is negative, display a message stating that there are no real solutions. 1 2 3 4 5 6 7 8 9 10 11 12 13 [...]]]></description>
			<content:encoded><![CDATA[<p>Write a Java program that prints all real solutions to the quadratic equation ax2+bx+c = 0. Read in a, b, c and use the quadratic formula. If the discriminant b2-4ac is negative, display a message stating that there are no real solutions.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Quadratic
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">double</span> x1,x2,disc,a,b,c<span style="color: #339933;">;</span>
		<span style="color: #003399;">InputStreamReader</span> obj<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedReader</span> br<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;enter a,b,c values&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		a<span style="color: #339933;">=</span><span style="color: #003399;">Double</span>.<span style="color: #006633;">parseDouble</span><span style="color: #009900;">&#40;</span>br.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		b<span style="color: #339933;">=</span><span style="color: #003399;">Double</span>.<span style="color: #006633;">parseDouble</span><span style="color: #009900;">&#40;</span>br.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		c<span style="color: #339933;">=</span><span style="color: #003399;">Double</span>.<span style="color: #006633;">parseDouble</span><span style="color: #009900;">&#40;</span>br.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		disc<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">*</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">*</span>a<span style="color: #339933;">*</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>disc<span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;roots are real and equal &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x1<span style="color: #339933;">=</span>x2<span style="color: #339933;">=-</span>b<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">*</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;roots are &quot;</span><span style="color: #339933;">+</span>x1<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">+</span>x2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>disc<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;roots are real and unequal&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x1<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>b<span style="color: #339933;">+</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span>disc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">*</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x2<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>b<span style="color: #339933;">+</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span>disc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">*</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;roots are &quot;</span><span style="color: #339933;">+</span>x1<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">+</span>x2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;roots are imaginary&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-prints-real-solutions-quadratic-equation-ax2bxc-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java program to display triangle 1 24 369 481216</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-1-24-369-481216/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-1-24-369-481216/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:29:29 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1356</guid>
		<description><![CDATA[/* Display Triangle as follow 1 2 4 3 6 9 4 8 12 16 ... N (indicates no. of Rows) */ class Output3{ public static void main(String args[]){ int n = Integer.parseInt(args[0]); for(int i=1;i]]></description>
			<content:encoded><![CDATA[<pre lang="java" line="1">
/* Display Triangle as follow<br />
   1<br />
   2 4<br />
   3 6 9<br />
   4 8 12 16 ... N (indicates no. of Rows) */<br />
class Output3{<br />
	public static void main(String args[]){<br />
		int n = Integer.parseInt(args[0]);<br />
		for(int i=1;i<=n;i++){<br />
			for(int j=1;j<=i;j++){<br />
				System.out.print((i*j)+" ");<br />
			}<br />
			System.out.print("\n");<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-1-24-369-481216/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to display triangle 0 10 101 0101</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-0-10-101-0101/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-0-10-101-0101/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:28:49 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1354</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 /* Display Triangle as follow 0 1 0 1 0 1 0 1 0 1 */ class Output2&#123; public static void main&#40;String args&#91;&#93;&#41;&#123; for&#40;int i=1;i&#60;=4;i++&#41;&#123; for&#40;int j=1;j&#60;=i;j++&#41;&#123; System.out.print&#40;&#40;&#40;i+j&#41;%2&#41;+&#34; &#34;&#41;; &#125; System.out.print&#40;&#34;\n&#34;&#41;; &#125; &#125; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* Display Triangle as follow
   0
   1 0
   1 0 1
   0 1 0 1 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Output2<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>j<span style="color: #339933;">&lt;=</span>i<span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span>2<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-0-10-101-0101/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java program to display triangle 1 23 456 78910</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-1-23-456-78910/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-1-23-456-78910/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:28:09 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1352</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /* Display Triangle as follow : BREAK DEMO. 1 2 3 4 5 6 7 8 9 10 ... N */ class Output1&#123; public static void main&#40;String args&#91;&#93;&#41;&#123; int c=0; int n = [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* Display Triangle as follow : BREAK DEMO.
   1
   2 3
   4 5 6
   7 8 9 10 ... N */</span>
<span style="color: #000000; font-weight: bold;">class</span> Output1<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> c<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
loop1<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;=</span>n<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
loop2<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>j<span style="color: #339933;">&lt;=</span>i<span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	       <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">!=</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		       c<span style="color: #339933;">++;</span>
		       <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	       <span style="color: #009900;">&#125;</span>
	       <span style="color: #000000; font-weight: bold;">else</span>
		       <span style="color: #000000; font-weight: bold;">break</span> loop1<span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
       <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-display-triangle-1-23-456-78910/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to find average of consecutive N Odd no. and Even no.</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-average-consecutive-odd/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-average-consecutive-odd/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:27:21 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1349</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class EvenOdd_Avg&#123; public static void main&#40;String args&#91;&#93;&#41;&#123; int n = Integer.parseInt&#40;args&#91;0&#93;&#41;; int cntEven=0,cntOdd=0,sumEven=0,sumOdd=0; while&#40;n &#62; 0&#41;&#123; if&#40;n%2==0&#41;&#123; cntEven++; sumEven = sumEven + n; &#125; else&#123; cntOdd++; sumOdd = sumOdd + n; &#125; n--; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> EvenOdd_Avg<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> cntEven<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,cntOdd<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,sumEven<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,sumOdd<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">%</span>2<span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				cntEven<span style="color: #339933;">++;</span>
				sumEven <span style="color: #339933;">=</span> sumEven <span style="color: #339933;">+</span> n<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				cntOdd<span style="color: #339933;">++;</span>
				sumOdd <span style="color: #339933;">=</span> sumOdd <span style="color: #339933;">+</span> n<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			n<span style="color: #339933;">--;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066; font-weight: bold;">int</span> evenAvg,oddAvg<span style="color: #339933;">;</span>
		evenAvg <span style="color: #339933;">=</span> sumEven<span style="color: #339933;">/</span>cntEven<span style="color: #339933;">;</span>
		oddAvg <span style="color: #339933;">=</span> sumOdd<span style="color: #339933;">/</span>cntOdd<span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Average of first N Even no is &quot;</span><span style="color: #339933;">+</span>evenAvg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Average of first N Odd no is &quot;</span><span style="color: #339933;">+</span>oddAvg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-average-consecutive-odd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to generate Harmonic Series 1 + 1/2 + 1/3 + 1/4 + 1/5</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-generate-harmonic-series-1-12-13-14-15/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-generate-harmonic-series-1-12-13-14-15/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:26:35 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Harmonic Series]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1347</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 /* Write a program to generate Harmonic Series. Example : Input - 5 Output - 1 + 1/2 + 1/3 + 1/4 + 1/5 = 2.28 (Approximately) */ class HarmonicSeries&#123; public static void main&#40;String args&#91;&#93;&#41;&#123; int num = Integer.parseInt&#40;args&#91;0&#93;&#41;; double [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* Write a program to generate Harmonic Series.
   Example :
   Input - 5
   Output - 1 + 1/2 + 1/3 + 1/4 + 1/5 = 2.28 (Approximately) */</span>
<span style="color: #000000; font-weight: bold;">class</span> HarmonicSeries<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> num <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">double</span> result <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span><span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">/</span> num<span style="color: #339933;">;</span>
			num<span style="color: #339933;">--;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Output of Harmonic Series is &quot;</span><span style="color: #339933;">+</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-generate-harmonic-series-1-12-13-14-15/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java program to demonstrate switch case</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-demonstrate-switch-case/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-demonstrate-switch-case/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:25:41 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[switch case]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1345</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* switch case demo
   Example :
   Input - 124
   Output - One Two Four */</span>
<span style="color: #000000; font-weight: bold;">class</span> SwitchCaseDemo<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> num <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> num<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//used at last time check</span>
			<span style="color: #000066; font-weight: bold;">int</span> reverse<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,remainder<span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				remainder <span style="color: #339933;">=</span> num <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
				reverse <span style="color: #339933;">=</span> reverse <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> remainder<span style="color: #339933;">;</span>
				num <span style="color: #339933;">=</span> num <span style="color: #339933;">/</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #003399;">String</span> result<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//contains the actual output</span>
			<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>reverse <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				remainder <span style="color: #339933;">=</span> reverse <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
				reverse <span style="color: #339933;">=</span> reverse <span style="color: #339933;">/</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>remainder<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Zero &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;One &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Two &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Three &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">4</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Four &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Five &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Six &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">7</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Seven &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">8</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Eight &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">9</span> <span style="color: #339933;">:</span>
						result <span style="color: #339933;">=</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Nine &quot;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
						result<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Invalid Number Format&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-demonstrate-switch-case/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java program to find whether no. is palindrome or not</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-palindrome/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-palindrome/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:24:43 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[palindrome]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1343</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /* Write a program to find whether no. is palindrome or not. Example : Input - 12521 is a palindrome no. Input - 12345 is not a palindrome no. */ class Palindrome&#123; public static void [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* Write a program to find whether no. is palindrome or not.
   Example :
   Input - 12521 is a palindrome no.
   Input - 12345 is not a palindrome no. */</span>
<span style="color: #000000; font-weight: bold;">class</span> Palindrome<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> num <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> num<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//used at last time check</span>
		<span style="color: #000066; font-weight: bold;">int</span> reverse<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,remainder<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			remainder <span style="color: #339933;">=</span> num <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
			reverse <span style="color: #339933;">=</span> reverse <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> remainder<span style="color: #339933;">;</span>
			num <span style="color: #339933;">=</span> num <span style="color: #339933;">/</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>reverse <span style="color: #339933;">==</span> n<span style="color: #009900;">&#41;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; is a Palindrome Number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; is not a Palindrome Number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-palindrome/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java program to find whether given no. is Armstrong or not</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-armstrong/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-armstrong/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 13:22:40 +0000</pubDate>
		<dc:creator>surajk</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[lab programs]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1339</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /*Write a program to find whether given no. is Armstrong or not. Example : Input - 153 Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */ class Armstrong&#123; public [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*Write a program to find whether given no. is Armstrong or not.
  Example :
  Input - 153
  Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */</span>
<span style="color: #000000; font-weight: bold;">class</span> Armstrong<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> num <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> num<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//use to check at last time</span>
		<span style="color: #000066; font-weight: bold;">int</span> check<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>,remainder<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			remainder <span style="color: #339933;">=</span> num <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
			check <span style="color: #339933;">=</span> check <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">pow</span><span style="color: #009900;">&#40;</span>remainder,<span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			num <span style="color: #339933;">=</span> num <span style="color: #339933;">/</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>check <span style="color: #339933;">==</span> n<span style="color: #009900;">&#41;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; is an Armstrong Number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; is not a Armstrong Number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-find-armstrong/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

