-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScannerProgram.java
More file actions
39 lines (35 loc) · 973 Bytes
/
ScannerProgram.java
File metadata and controls
39 lines (35 loc) · 973 Bytes
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
package COE;
import java.util.*;
import java.io.*;
public class ScannerProgram {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number : ");
int n = sc.nextInt();
System.out.print("The Fibonacci Series is ");
if(n >= 1)
System.out.print("0 ");
if(n >= 2)
System.out.print("1 ");
int fn = 0, sn = 1, nn;
for(int i = 3; i <= n; i++)
{
nn = fn + sn;
System.out.print(nn + " ");
fn = sn;
sn = nn;
}
System.out.println();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter an Integr : ");
int i = Integer.parseInt(br.readLine());
System.out.print("Enter a Character : ");
char c = (char)br.read();
br.readLine();
System.out.print("Enter a String : ");
String s = br.readLine();
System.out.println(i + " " + c + " " + s);
br.close();
sc.close();
}
}