Search This Blog

Sunday, 26 February 2017

JAVA Program for printing text file in parts

//Aim  : Program for printing text file in parts
import java.io.*;
import java.util.*;
class TestPart
{
public static void main(String[] a)
{
try
{
FileReader f=new FileReader("PrintPart.txt");
BufferedReader b=new BufferedReader(f);
String s;
s="  ";
L:
while(s!=null )
{
for(int i=0;i<5;i++)
{
s=b.readLine();
if(s==null)
break L;
System.out.println(s);
}
System.out.println("Press Enter Key To Continue.......");
if(System.in.read()==13 && System.in.read()==10)
continue;
else
break L;
}
}
catch(Exception e)
{
System.out.println("Error!");
}
}
}

Output :

E:\MyJava>javac TestPart.java

E:\MyJava>java TestPart
1
2
3
4
5
Press Enter Key To Continue.......

6
7
8
9
10
Press Enter Key To Continue.......

11
12
13
14
15
Press Enter Key To Continue.......

16
17
18
19
20
Press Enter Key To Continue.......

21
22
23
24
25
Press Enter Key To Continue.......

26
27
28
29
30
Press Enter Key To Continue.......

31
32
33
34
35
Press Enter Key To Continue.......

36
37
38
39
40
Press Enter Key To Continue.......

41
42
43
44
45
Press Enter Key To Continue.......

46
47
48
49
50
Press Enter Key To Continue.......


E:\MyJava>

Saturday, 25 February 2017

Arithmatic operations in MATLAB using switch case


Python program for measuring time complexity


import time
t1 = time .time()

for i in range(1,1000):
    if i%2==0:
        print(str(i)+"num is even")
    else :
        print(str(i)+"num is odd")
       
t2 = time.time()
t3 = t2 - t1
print(t2,t1)
print(t3)