Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please solve with out the use of arrays object and write all the code in one cla

ID: 3735622 • Letter: P

Question

Please solve with out the use of arrays object and write all the code in one class (accountNumberSearch class) do not do multible classes like do the bubble sorting logic and the binarysearch logic inside that class The second photo it has the array that u supposed to use in the actual program Please do not use the array object use the actual loops and logic operation for searching and binacy sorting Create a program that allows the user to enter an account number and prints if the number entered exists in the array provided in the source code. Your program must: First sort the array into descending order o You must implement a bubble sort, insertion sort, or selection sort algorithm o Do not use an external class like the Arrays object Then, prompt the user to enter a seven-digit account number Implement a binary search to determine if the number the user entered exists in the array o Again, do not use an external class like the Arrays object. .If it does exist, print that the account number is valid and end the program o Otherwise, print that the account number is invalid and allow the user to try again Please ebte a ublic class Accounts aberSeareth , Hain Hethoa. This is vhere the prograt begina. public statio void main(Stringt) arga) t insti accounui ater, -17si016, -3504e, ,EL.se, 1131:14. 071228 4904090, 392623, 7265560 9982399, 5347659,3229602 5607213. 6370765 709008 417942 592534

Explanation / Answer


import java.util.Scanner;
public class AccountNumberSearch
{
public static void sort(int array[])//Implemented Bubble Sort Algorithm
{
int n = array.length;
int k;
int temp;
for (int m = n; m >= 0; m--)
{
for (int i = 0; i < n - 1; i++)
{
k = i + 1;
if (array[i] > array[k])
{
temp = array[i];
array[i] = array[k];
array[k] = temp;
}
}
}
}
public static int Search(int[] Arr, int accountnumber)
{
int x = 0;
int y = Arr.length - 1;
while (x <= y)
{
int mid = (x + y) / 2;
if (accountnumber == Arr[mid])
{
return mid;
}
if (accountnumber < Arr[mid])
{
y = mid - 1;
} else
{
x = mid + 1;
}
}
return -1;
}
public static int digit(int d)
{
int temp=d,r=0;
while(temp>0)
{
r++;
temp=temp/10;
}
if(r==7)
{
return 1;
}
return 0;
}
public static void main(String args[])
{
int[] accountNumbers={7151016, 2330468, 1761406, 1731214,
5071218, 1904090, 3928623, 7265960,
9982399, 5347659, 3229601, 5607213,
6370765, 7109003, 4179542, 5925341,
2986639, 7169441, 9987029, 6702898};
//You please verify the account numbers because they're not visible crystal clearly.
Scanner scan=new Scanner(System.in);
int trigger=0,trigger2=0;
System.out.println("Enter accountNumber:");
int serch=scan.nextInt();
while(serch>0&&trigger==0)
{
if(trigger2==1)
System.out.println("Enter accountNumber:");
serch=scan.nextInt();
while(digit(serch)==0)
{
System.out.println("Enter a 7-digit accountNumber:");
serch=scan.nextInt();
}
sort(accountNumbers);
int finall=Search(accountNumbers, serch);
if(finall>=0)
{
System.out.println(""+serch+" is valid");
trigger=1;
}else
{
System.out.println(""+serch+" is invalid");
}
}
}
}