In java language: Ask for keyboard input of a decimal number. Use a loop to keep asking for input of up to ten numbers. Exit the loop if ten numbers are entered or if a sentinel value for “QUIT” is entered. Store the numbers in an array. Sort the array according to ascending number. Get the average for all the numbers in the array. Print out the average. Calculate the distance from the average for each number in the array and print out the difference. Use a binary search method to search for a number in the array and display to the console
import java.util.Scanner;
class Main{
public static void main(String[] args) {
Scanner obj = new Scanner(System.in);
int arr[] = new int[10];
int size = 0;
System.out.println("Enter numbers");
while(size<10){
// System.out.println("Enter a number");
String no = obj.nextLine();
if(no.equals("QUIT")){
break;
}
arr[size++] = Integer.parseInt(no);
}
for(int i=0;i<size;i++){
for(int j=i+1;j<size;j++){
if(arr[i]>arr[j]){
int t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
}
}
System.out.println("After sorting");
for(int i=0;i<size;i++){
System.out.print(arr[i]+" ");
}
System.out.println();
double sum = 0;
for(int i=0;i<size;i++){
sum += arr[i];
}
double avg = sum/size;
System.out.println("Average is "+avg);
System.out.println("Difference to average is : ");
for(int i=0;i<size;i++){
System.out.println(arr[i]+" "+Math.abs(arr[i]-avg));
}
//Perform binary search
System.out.println("Enter the element");
int el = obj.nextInt();
int start =0;
int end = size;
int mid = (start+end)/2;
//Dp until start<end
while(start<=end){
if(arr[mid]==el){
System.out.println("Found");
break;
}
if(arr[mid]>el){
end = mid-1;
}
else{
start = mid+1;
}
mid = (start+end)/2;
}
}
}
OUTPUT :

In java language: Ask for keyboard input of a decimal number. Use a loop to keep...
Write code in c
prototypes for ConvertDecimalToBinary and PrintBinary function ConvertDecimalToBinary0 pass in input decimal number and array to hold binary number (8 cells 1 for each bit) In for loop, use right bitshift to divide by 2 In for loop, use a bitmask to determine if odd or even and ternary if to assign 1 or 0 to bit array function PrintBinary pass in binary number array Use for loop to print out each element of binary number array...
Using Java Create an application that creates and displays a list of names using an array. Then modify the application to create and use a list of numbers. Console for the names application Please enter a name or type “exit” to quit: Diane Please enter a name or type “exit” to quit: Joe Please enter a name or type “exit” to quit: Greta Please enter a name or type “exit” to quit: Henry Please enter a name or type “exit”...
Write a Java program that will create an array of Strings with 25 elements. Input Strings from the user and store them in the array until either the user enters “quit” or the array is full. HINT: the sentinel value is “quit” all lowercase. “Quit” or “QUIT” should not stop the loop. HINT: you have to use the equals method (not ==) when you are comparing two Strings. After the input is complete, print the Strings that the user entered...
Unit 4 Assignment 5: Coding Project using C# Binary Search Scenario Use the same integer array named partNumbers that you used for task 3. Sort the array in ascending order. 1065, 1095, 1075, 1055, 1056, 1090, 1098, 1088, 1097, and 1078. Java: use Array.sort() C#: use Array.Sort() PHP: use sort() Write code that asks the user to enter two part numbers. For C#, use console input. Implement a binary tree search function called binarySearch() to search the array for the...
C language: P14. Ask a user for three positive integer numbers. Use an input valiadation loop to make sure that all numbers are positive, ask again if not. Determine the smallest, middle and largest number and display them with proper labeling (Smallest=AA, Middle=BB, Largest=CC).
This program is in C++ Write a program that validates charge account numbers read in from the file Charges.txt following this assignment (A23 Data). Use a selection sort function on the array to sort the numbers then use a binary search to validate the account numbers. Print out the sorted list of account numbers so you can see the valid ones. Prompt the user to enter an account number and the validate that number. If the account number entered is...
Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...
LANGUAGE = C i. Write a program that takes int numbers from user until user gives a sentinel value (loop terminating condition). Sort the numbers in ascending order using Insertion sort method. Sorting part should be done in different function named insertionSort(). Your code should count the number of swaps required to sort the numbers. Print the sorted list and total number of swaps that was required to sort those numbers. (4 marks) ii. In this part take another number...
Please complete this code for java
Lab Write a program as follows: Create an array with 10 elements. The array should contain numbers generated randomly between 1 and 100 Ask the user to enter any number - Search the array to see if the user entered number is in the array If the user-entered number is in the array, print a 'match found' message. Also print at which index the match was found, else print a 'match not found' message...
Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...