Page 569 - Computer science 868 Class 12
P. 569
INTERNAL ASSESSMENT
Marks: 15
PROGRAMS FOR PROJECT FILE ONE-DIMENSIONAL ARRAY
Program 1 Define a class Bubble_Binary to create an array and perform the following:
Class name : Bubble_Binary
Members Method
nt n : accepts array size
int sno : accepts number to be searched by the user
int ar[] : array of the elements
Member Functions
Bubble_Binary () : constructor that initialised member data to zero
void accept() : accepts data from the user
void bubble() : sort the given array in ascending order
void binary() : searches the number using binary search
1 import java.util.*;
2 class Bubble_Binary
3 {
4 int n,sno , ar[]; // member data
5 Scanner sc=new Scanner(System.in);
6 Bubble_Binary()
7 {
8 n=sno=0;
9 }
10 void accept() //input
11 {
12 System.out.println("ENTER SIZE OF THE ARRAY");
13 n=sc.nextInt();
14 ar=new int[n];
15 System.out.println("ENTER ARRAY ELEMENTS");
16 for(int i=0;i<n;i++)
17 ar[i]=sc.nextInt();
567
Internal Assessment 567

