BSC IT PRACTICALS

Friday, February 9, 2018

Designed a class SortData that contains the method asec() and desc() in java

February 09, 2018 3
Designed a class SortData that contains the method asec() and desc() in java
import java.util.*; class prac4A { Scanner input=new Scanner(System.in); int num,i; int arr[]; int temp=0; public void getdata() { System.out.print("Enter the size of array: "); num=input.nextInt(); arr=new int[num]; System.out.print("Enter the number: "); for( i=0;i<num;i++) { arr[i]=input.nextInt(); } } void putdata() { System.out.print("Given numbers are: "); for(i=0;i<num;i++) { System.out.println(arr[i]); } } void asce() { for(i=0;i<num;i++) { for(int...

Write a java program to demonstrate the implementation of abstract class.

February 09, 2018 1
 Write a java program to demonstrate the implementation of abstract class.
import java.util.Scanner; abstract class test { abstract void get(); } class test1 extends test { void get() { int a,b; Scanner ob=new Scanner(System.in); System.out.print("Enter 1st Number: "); a=ob.nextInt(); System.out.println("Enter 2st Number: "); b=ob.nextInt(); System.out.println("Addition is: "+(a+b)); } } class prac4C { public static void main(String args[]) { test1 obj=new test1(); obj.get(); } } ...

Designed a class that demonstrates the use of constructor and destructor in java

February 09, 2018 32
Designed a class that demonstrates the use of constructor and destructor in java
class xyz { xyz() { System.out.println("Constructor method........"); } protected void finalize() { System.out.print("Garbage Collected....."); } } class prac4B { public static void main(String args[]) { xyz ob=new xyz(); ob=null; System.gc(); }...

Friday, January 19, 2018

Java function that calculates the sum of digits for a given char array consisting of the digits '0' to '9'. The function should return the digit sum as a long value

January 19, 2018 0
Java function that calculates the sum of digits for a given char array consisting of the digits '0' to '9'. The function should return the digit sum as a long value
CODE: import java.util.*; class prac3B { public static void main(String args[]) { Scanner ob=new Scanner(System.in); System.out.print("Enter the any string: "); String s=ob.nextLine(); count(s); } public static void count(String str) { int sum=0; int d=0; char ch[]=str.toCharArray(); for(int i=0;i<str.length();i++) { if(Character.isDigit(ch[i])) { sum+=Character.getNumericValue(ch[i]); } } System.out.println("Your addtion is: "+sum); }...

Find the smallest and largest element from the array in java

January 19, 2018 0
 Find the smallest and largest element from the array in java
CODE: class prac3C {   public static void main(String args[])   {         int num[]=new int[]{10,20,30,5}; int s=num[0]; int l=num[0]; for(int i=0;i<num.length;i++) {     if(l<num[i]) {   l=num[i];   }   else   {     s=num[i]; } } System.out.println("Largest Number are:"+l); System.out.println("Smallest number are: "+s); ...

Java program to count the letters, spaces, numbers and other characters of an input string

January 19, 2018 1
Java program to count the letters, spaces, numbers and other characters of an input string
CODE: import java.util.*; class prac3A { public static void main(String args[]) {     Scanner input=new Scanner(System.in); System.out.print("Enter A String: "); String str=input.nextLine();      int letter=0,space=0,digit=0,other=0;    char ch[]=str.toCharArray(); for(int i=0;i<str.length();i++) {    if(Character.isLetter(ch[i]))    {        letter++;   } ...

Thursday, January 18, 2018

OOPS Write a program to demonstrate function definition outside class and accessing class members in function definition.

January 18, 2018 3
OOPS Write a program to demonstrate function definition outside class and accessing class members in function definition.
CODE: #include<iostream.h> #include<conio.h> class fibo { public: void fibonacci(); }; void fibo::fibonacci() {    int t1 = 0, t2 = 1, nextTerm = 0, n;     cout << "\nEnter a positive number to calculate \nthe Fibonacci series upto entered number: ";     cin >> n;     cout << "\nFibonacci Series: " << t1 << ", " << t2 << ", ";    ...
Page 1 of 51235Next