import java.util.*;
class Fibonacci
{
int n;
Fibonacci()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter the number of terms: ");
n=s.nextInt();
}
void show()
{
int f=0,s=1,t;
System.out.print(f+","+s);
for(int i=3;i<=n;i++)
{
t=f+s;
System.out.print(","+t);
f=s;
s=t;
}
}
}
class TestFibo
{
public static void main(String args[])
{
Fibonacci f= new Fibonacci();
f.show();
}
}
class Fibonacci
{
int n;
Fibonacci()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter the number of terms: ");
n=s.nextInt();
}
void show()
{
int f=0,s=1,t;
System.out.print(f+","+s);
for(int i=3;i<=n;i++)
{
t=f+s;
System.out.print(","+t);
f=s;
s=t;
}
}
}
class TestFibo
{
public static void main(String args[])
{
Fibonacci f= new Fibonacci();
f.show();
}
}
-
Next Design a screen in Java to handle the Mouse Events such as MOUSE_MOVED and MOUSE_CLICK and display the position of the Mouse_Click in a TextField.
-
Previous Write a java program to read the characters from a file, if a character is alphabet then reverse its case, if not then display its category on the Screen. (whether it is Digit or Space)
0 Comments