Posts

Showing posts from November, 2022
//Enter decimal values in Descending order in an array  and search for a specific number. If it is found then print its index Number otherwise print Not Found  import java.util.*; class binarySearch//Binary search Descending order {    public static void main(String args[])    {    Scanner ob=new Scanner(System.in);    System.out.println("Enter No of Elements");    int n=ob.nextInt();    double ar[]=new double[n];    int i,ind=-1;    System.out.println("Enetr Decimal values in Descending Order\n");    for(i=0;i<n;i++)    {    ar[i]=ob.nextDouble();//enter values in Descending order    }    System.out.println("Enetr SEARCH  NUMBER in DECIMAL");    double sp=ob.nextDouble();    int beg=0,last=n-1,mid=0;    while(beg<=last)    {    mid=(beg+last)/2;  ...
 //Tech number 2025 = 20 +25 =45 * 45 =2025 //printing all 4 digit Tech numbers class tech { public static void main(String arg[]) { for(int i=1000;i<=9999;i++) { int cpy,fst,lst; cpy=i; lst=cpy%100; fst=cpy/100; int sq=(int)Math.pow((fst+lst),2); if(sq==cpy) System.out.print(i+"\t"); } } } /* Output: 2025    3025    9801     Press any key to continue . . . /*
 //Finding LCM of 3 Numbers of integer type import java.util.*; class lcm { public static void main(String arg[]) { Scanner ob=new Scanner(System.in); System.out.println("Enter 3 Numbers"); int a=ob.nextInt(); int b=ob.nextInt(); int c=ob.nextInt(); int i; for(i=1; ;i++) { if(i%a==0 && i%b==0 && i%c==0) break; } System.out.println("LCM is \t"+i); } } /* Input: Enter 3 Numbers 15 6 7 Output: LCM is  210 Press any key to continue . . . */
//Dequeue /* A doubly queue is a linear data structure which enables the user to add and remove integers from either ends, i.e. from front or rear. Define a class Dequeue with the following details: [10] Class name: Dequeue Data members/instance variables: arr[ ]: array to hold up to 100 integer elements lim: stores the limit of the dequeue front: to point to the index of the front end rear: to point to the index of the rear end Member functions: Dequeue(int t): constructor to initialize the data members lim = t; front = rear = -1 void addfront(int val): to add integer from the front if possible else display the message (“Overflow from front”) voidaddrear(intval): to add integer from the rear if possible else display the message (“Overflow from rear”) int popfront(): returns element from front, if possible otherwise returns – 9999 int poprear(): returns element from rear, if possible otherwise returns – 9999 Specify the class Dequeue giving details of the constructor (int), void addfro...
 //Program to show working of replace () method  //executed in textpad (Java editor) public class check { public static void main(String arg[]) { String x="AdityA"; System.out.println(x.replace("Adi","4")); } } // Output: 4tyA