In JAVA Create a program with an array with the following data:
50 12 31 76 5 23 15
Use a text file (.txt created in notepad) to read the data into the array.
Write a sort method (your choice of sorting algorithm) to sort the array values values - highest to lowest. Write a method to determine the minimum value. Your program should call the sort and minimum methods. Output the sorted array and minimum value.
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
public class Main
{
public static void main(String[] args) throws
Exception{
Scanner sc = new Scanner(new BufferedReader(new
FileReader("sample.txt")));
ArrayList<Integer> arr = new
ArrayList<Integer>();
while(sc.hasNextLine()) {
arr.add(Integer.parseInt(sc.nextLine()));
}
sort(arr);
minimum(arr);
}
static void sort(ArrayList<Integer> arr)
{
for(int i=0;i<=arr.size();i++)
{
for(int j=i+1;j<arr.size();j++)
{
if(arr.get(i)<arr.get(j))
{
int temp=arr.get(i);
arr.set(i,arr.get(j));
arr.set(j,temp);
}
}
}
System.out.println("sorted array :- ");
for(int i=0;i<arr.size();i++)
System.out.print(arr.get(i)+" ");
}
static void minimum(ArrayList<Integer>
arr)
{
int min =arr.get(0);
for(int i=1;i<arr.size();i++ )
if(min<arr.get(i))
min=arr.get(i);
System.out.println("\nminimum :- "+min);
}
}
In JAVA Create a program with an array with the following data: 50 12 31 76...
Create a JAVA program with an array with the following data: 50 12 31 76 5 23 15 Use a text file (.txt created in notepad) to read the data into the array. Write a sort method (your choice of sorting algorithm) to sort the array values values - FROM HIGHEST TO LOWEST. Write a method to determine the minimum value. Your program should call the sort and minimum methods. Output the sorted array and minimum value.
java ASAP Assume that you have tracked daily minutes of you work out for a week. Save the following data into a text file in a notepad. 50 10 36 11 47 30 Write a java program that reads the minutes for a week from the text file that you created. Read the minutes from the input file into the array in one execution of the program.write a java method to find out the maximum and minimum values. Your program...
IN JAVA Write a program that uses a two-dimensional array to store daily minutes walked and carb intake for a week. Prompt the user for 7 days of minutes walked and carb intake; store in the array. Write a sort ( your choice which sort ) to report out the sorted minute values -lowest to highest. Write another to report out the sorted carb intake - highest to lowest. These methods MUST be your original code. Your program should output...
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...
Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the merge sort algorithm. The basic steps of merge sort are: 1) divide a collection of items into two lists of equal size, 2) use merge sort to separately sort each of the two lists, and 3) combine the two sorted lists into one sorted list. Of course, if the collection of items is just asingle item then merge sort doesn’t need to perform the three steps,...
In java create a program to test and measure an actual running time of Insertion sort and Merge sort on your machine. Each sorting algorithm must be a separate method: a. Randomly generate 100 integers between 0 and 500. b. Store those integers in an array and display them on screen. c. Using each sorting algorithm, sort numbers and display the sorted numbers. The array must be passed as an argument to call a method. d. For each sorting algorithm,...
The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
Write a complete JAVA program to do the following program.
The main program calls a method to read in (from an input file) a set of people's three-digit ID numbers and their donations to a charity (hint: use parallel arrays)Then the main program calls a method to sort the ID numbers into numerical order, being sure to carry along the corresponding donations. The main program then calls a method to print the sorted 1ists in tabular form, giving both ID...
java pseudocode and source code help?
Write a program that uses an array of high temperatures for your hometown from last week (Sunday - Saturday). Write methods to calculate and return the lowest high temperature (minimum) and a method to calculate and return the highest high temperature (maximum) in the array. You must write YOUR ORIGINAL methods for minimum and maximum. You MAY NOT use Math class methods or other library methods. Write an additional method that accepts the array...