ave been disabled because it hasn't been activated. Activate Requirements 1. Insertion Sort Write…

Code in java

ave been disabled because it hasnt been activated. Activate Requirements 1. Insertion Sort Write a static method to sort an array of doubles using the insertion sort. You must use the insertion sort algorithm and write code to implement it Put the insertion sort algorithm in its own class. a. b. c. Do not depend on the length of the array. Instead, provide a parameter that gives the number of values to be sorted d. Sort the values in descending order. That is, the largest number should end up as the first number in the array. e. The sort method does not perform any /o (reads/writes) User interface class a. Create a second class which will contain your main() method. b. Your main) method will call the sort method c. Display the values you are going to sort, then sort them and then display them in sorted order d. Display your name 2. Files and Exceptions a. Read the values to be sorted from a file. b. Prompt the user for the name of the file. c Implement exception handling. if an error occurs, give a meaningful error message and stop the 3. program. d. Ataminimyum specticaiy cateh thie extionsthst occur when o the file cannot be found o values in the file are not numbers o a reference is made past the end of the array o a reference is made to a null object e. Catch all other exceptions f. The format of the file will be: number number
media%2F256%2F256c054d-e9f7-4910-84ca-ad
media%2F10d%2F10d88ca3-9742-4118-ad6e-32
media%2F351%2F351526ed-773b-4826-a225-56

ave been disabled because it hasn’t been activated. Activate Requirements 1. Insertion Sort Write a static method to sort an array of doubles using the insertion sort. You must use the insertion sort algorithm and write code to implement it Put the insertion sort algorithm in its own class. a. b. c. Do not depend on the length of the array. Instead, provide a parameter that gives the number of values to be sorted d. Sort the values in descending order. That is, the largest number should end up as the first number in the array. e. The sort method does not perform any /o (reads/writes) User interface class a. Create a second class which will contain your main() method. b. Your main) method will call the sort method c. Display the values you are going to sort, then sort them and then display them in sorted order d. Display your name 2. Files and Exceptions a. Read the values to be sorted from a file. b. Prompt the user for the name of the file. c Implement exception handling. if an error occurs, give a meaningful error message and stop the 3. program. d. Ataminimyum specticaiy cateh thie extionsthst occur when o the file cannot be found o values in the file are not numbers o a reference is made past the end of the array o a reference is made to a null object e. Catch all other exceptions f. The format of the file will be: number number

Expert Answer

answers

Hello There,

Don't use plagiarized sources. Get Your Custom Essay on
ave been disabled because it hasn't been activated. Activate Requirements 1. Insertion Sort Write…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

Some instruction to remember before running program :

1. File that has values must contain inside the folder where a program is located.

2. Must have to provide .txt extension with a file name in a program such as if your file name is sample then string should be sample.txt

3. You have to save all the program separately

4. All the exceptions and other requirement has been handled

5. Just copy the program and save as .java and create .class file for both program

6. A file which has values have to created by you

7. Please change your name is a program where I specified

8. An output is attached to the program

9. The program has two class so save as same name as the ​class

Class InsertionSortClass :

public class InsertionSortClass{

static void sort(double array[],int len)
{
int i, j;
double key ;
for (i = 1; i < len; i++)
{

key = array[i];
j = i-1;

while (j >= 0 && array[j] < key)
{
array[j+1] = array[j];
j = j-1;
}
array[j+1] = key;
}
}
}

class UserInterfaceClass :

import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;

public class UserInterfaceClass extends InsertionSortClass
{
public static void main(String args[])
{
InsertionSortClass obj = new InsertionSortClass();

ArrayList<String> rows = null ;
File input = null ;

String inputFileName;

System.out.println(“Hello there ! My name is “) ; //Yourname here

// double[] arr1 = {9,14,3,2,43,11,58,22}; //you can statically provide value here and pass as parameter in fuction too

try
{
System.out.print(“Enter File Name — > “); //note filename must contains .txt extension in input
Scanner sc = new Scanner(System.in ); //Enter File name
inputFileName = sc.nextLine().trim();
input = new File(inputFileName);
System.out.println(“File Name : ” +inputFileName + “n”);

try{
rows = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new FileReader(input));

String s;
while((s = reader.readLine())!=null)
rows.add(s);

reader.close();

}
catch(FileNotFoundException file)
{
System.out.println(“No such File available”);
}
catch(NumberFormatException num)
{
System.out.println(“File Doesnt Contains number values”);
}
catch(IOException e)
{
System.out.println(e);
}

double[] arr1 = new double[rows.size()]; //convert value of file that is string into double

for (int i = 0; i < rows.size(); ++i) { //iterate over the elements of the list
arr1[i] = Double.parseDouble(rows.get(i)); //store each element as a double in the array
}

System.out.println(“****** Before Insertion Sort ******”);
for(double i:arr1){
System.out.print(i+” n”);
}
System.out.println();

int number = arr1.length ; //no limit in number of values

InsertionSortClass.sort(arr1 ,number) ;

System.out.println(“****** After Insertion Sort *******”);
for(double i:arr1){ //print array
System.out.print(i+” n”);

}
}

catch(NullPointerException empty)
{
System.out.println(“Sorry File is empty”);
}
catch(Exception e)
{
System.out.println(e);
}

}
}

output : This PO cmd :python java UserInterfaceClass ello there My name is Enter File Name -- > sample.txt File Namesample.txt run:l h Before Insertion Sort 11.8 After Insertion Sort** 56.0 7.e 11.0 python Panel Cleanu Downloader Torrent 15 16 Type here to search ^ 1x ENG 01-11-2018

Top Grade Homework
Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents