Posts

Showing posts from September, 2018

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY-TO GERNERATE RANDOM NUMBER USING LINEAR CONGRUENTIAL METHOD IN JAVA

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY GERNERATE RANDOM NUMBER USING  LINEAR CONGRUENTIAL METHOD IN JAVA PROGARM:  import java.util.*; public class myRnd {         final int m,a,b;      int x;   public myRnd(){             Scanner in=new Scanner(System.in);         System.out.println("enter the value of m");         m=in.nextInt();                 System.out.println("enter the value of a");         a=in.nextInt();         System.out.println("enter the value of b");         b=in.nextInt();                               x = m / 2;   }          double next() {           ...

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY-Create user defined Exception Handling in Java

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY CREATE A USER DEFINED EXCEPTION HANDLING IN JAVA  PROGRAM: import java.util.Scanner; import java.io.*; public class Demo{ public static void main(String args[]){ try { int ch;   System.out.println("enter\n1.arithmeticexception\n2.arrayindexOfBoundexception\n3.Nullpointerexception\n4.NumberFormtexception \n enter your choice:\n"); Scanner in=new Scanner(System.in); ch=in.nextInt(); switch(ch) {   case 1:            int  a;            a=args.length;            System.out.println("a"+a);            int b=42/a;             break; case 2:            int c[]={1};            c[42]=99;            break; case 3:             ...

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY-FILE HANDLING METHODS

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY QUESTION :Write a Java program that reads a file name from the user, displays information about whether the file exists, whether the file is readable, or writable, the type of file and the length of the file in bytes PROGRAM: import java.io.*; import java.util.Scanner; class Opfile{     Scanner sc= new Scanner(System.in); void show(){     String fname; //getting file name from user System.out.println("enter file name");         fname=sc.next();         //assign as file name         File f= new File(fname);          String line=null;         try         {              FileReader fileReader=new FileReader(f);                              ...