Program produces 1000 integer ranging

Assignment Help JAVA Programming
Reference no: EM13163543

Part A.1 Do a selection sort according to the textbook using the random number generator. (You may copy the code from the textbook for the sorting algorithm). Your program asks the size of data and the range of data (smallest int and the largest int). Then you generate the number of data within the range of the data. You write the data into a file as shown below.

Program Sorting> Please enter the size of data: 1000
Program Sorting> Please enter the smallest value:1
Program Sorting> Please enter the largest value:10000
Program Sorting> Please enter the name of data file: data1

Then your program produces 1000 integer ranging from 1to 10000 in the array and then sort them in ascending order and then print the result into data.txt file. (You may list integers separated by space or new line)
Part A.2 Now you implement two search methods - linear search and binary search. You can use the sorted array from Part A.1 by continuing Part A Program to ask for keys to search. And you are required to read a data file provided by me as an input file. The name of input file should be given as an input argument to your program as below;

Java MySearch.class data1.txt

If argument is not given, then the program uses the default setting of the sorted array from the randomly produced data at A.1.

Program SortingAndSearch> Please enter the size of data: 1000
Program SortingAndSearch> Please enter the smallest value:1
Program SortingAndSearch> Please enter the largest value:10000
Program SortingAndSearch> Please enter the name of data file: data1
Program SortingAndSearch> Enter a key to search: 9999
Found at index 999 after 999 iterations of linear search
Found at index 999 after 9 iterations of binary search
Do you like to continue? Enter a key (negative int means you want to quit): 500
Found at index 49 after 49 iterations of linear search
Found at index 49 after 9 iterations of binary search
Do you like to continue? Enter a key (negative int means you want to quit): -1

Reference no: EM13163543

Questions Cloud

Write a scanf statement to read in one number (int : 1) Write a scanf statement to read in one number (int), and another statement to print out that number.
Combustion studies of the use of h2 as an alternative fuel : In combustion studies of the use of H2 as an alternative fuel, HO is sometimes formed in flames by the reaction, H(g) + 1/2 O2(g) HO(g) Use the data below to calculate the value of Kc
Compares the number of possible sequences : A c++ program that compares the number of possible sequences of the length L that can be generated uinder the following assumptions. Given an alphabet of size N=9. The program must output a formatted list comparing the number of possible sequences..
How many vitamin c molecules are contained in the tablet : A vitamin tablet contains 501 mg of vitamin C (C6H8O6). How many vitamin C molecules are contained in the tablet?
Program produces 1000 integer ranging : Then your program produces 1000 integer ranging from 1to 10000 in the array and then sort them in ascending order and then print the result into data.txt file. (You may list integers separated by space or new line)
Arrange compounds in order of increasing boiling point : Arrange these compounds in order of increasing boiling point: CH3CH2CH2OH CH3CH2CH3 CH3CH3 CH3CH2CH2Cl Rank from smallest to largest
Calculate the equilibrium concentrations for all of species : At a particular temperature, K=2.0x10^-6 mol/L for the following reaction: 2CO2 (g) at equilibrium with 2CO(g) + O2 (g) If 2.1 mol CO2 is initially placed into a 4.2 L vessel, calculate the equilibrium concentrations for all of the species.
Meaning of discounted value of expected net receipts : What is the meaning of "discounted value of expected net receipts and what basis of valuation for Ferry's patents would be generally accepted in accounting? Give supporting reasons for this basis.
Determine the percentage purity of nahco3 : a sample of sodium hydrogencarbonate, NaHCO3 is contaminated with 5-10% NaCl. How should i carry out an experiment to determine the percentage purity of NaHCO3 ?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Understand actual communication with an smtp server

Understand actual communication with an SMTP server can be achieved using TCP Sockets and understand the development of a graphical user interface (GUI) and use of event handling.

  Design a course registration system

Create an application which represents a simplified course registration system using ArrayLists and HashMaps.

  Minimal spanning tree decreasing edge dismissal

Minimal Spanning Tree Decreasing Edge Dismissal, Reverse-delete algorithm. Develop an implementation that computes the MST

  The string class and/or the stringbuffer class in java

Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.

  Explain java-oriented microprocessors presented by sun

Research the latest Java-oriented microprocessors presented by Sun. In what ways are they optimized to implement Java programs?

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

  Reads in up to 1000 non-negative integers

Write a program that reads in up to 1000 non-negative integers and displays distinct numbers (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read each number and store it in an array if it is new. If the number is alread..

  Create java applet to represent grade of gas

Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use.

  Java application which creates bank records

Write down a java application which creates 10000 bank records and the allow user ti enter a balance and customer account info. using a an account number.

  Give an implementation of the queue adt using an array

Give an implementation of the Deque ADT using an array, so that each of the update methods run in O(1) time. Program has to be written in Java.

  Java application to display multiple choice questions

Write down the application which displays series of TEN(10) multiple choice questions: questions must cover all the Java. Each question must have four possible answers and only one answer must be correct.

  Write a program to register students for a college

Students have names, addresses and courses. Implement the interface class RegisterStudent. RegisterStudent has one method, public boolean register, which returns the boolean value of true or false if the student is successfully registered for the ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd