Difference between revisions of "Fibonacci sequence"
From CompSciWiki
Line 3: | Line 3: | ||
|ProblemName=Fibonacci sequence | |ProblemName=Fibonacci sequence | ||
− | |Problem= | + | |Problem=Write a complete Java program Fibonacci that:<br/> |
*prompts the user to enter an input n and cast it to integer<br/> | *prompts the user to enter an input n and cast it to integer<br/> | ||
*get the nth fibonacci numbers using ''FOR'' loop, based on the user's input<br/> | *get the nth fibonacci numbers using ''FOR'' loop, based on the user's input<br/> | ||
Line 14: | Line 14: | ||
<br/> | <br/> | ||
You may assume that the user always enters correct intenger format.<br/> | You may assume that the user always enters correct intenger format.<br/> | ||
− | + | ||
− | |SolutionCode= | + | |SolutionCode=<pre> |
import javax.swing.JOptionPane;<br/> | import javax.swing.JOptionPane;<br/> | ||
<br/> | <br/> | ||
Line 36: | Line 36: | ||
System.out.println("The " + n + "th Fibonacci number is " + current);<br/> | System.out.println("The " + n + "th Fibonacci number is " + current);<br/> | ||
}<br/> | }<br/> | ||
− | + | } | |
− | + | </pre> | |
|SideSectionTitle=...by students | |SideSectionTitle=...by students | ||
Revision as of 23:22, 1 April 2010
Back to the Program-A-Day homepage
ProblemWrite a complete Java program Fibonacci that:
|
...by students
An image or By Students section | |
---|---|---|
Solution | ||
Code |