In Java
step 1)
Assume that you have tracked monthly theater movies for 5 months. Save the following data into a text file in notepad in order listed here: 1414 1126 1357 1289 1126
Step 2)
Write a java program that reads the movie tickets sold for 5 months for the text file that you created in step 1. Read the monthly tickets from the input file into an array in one execution of the program. Write a sort method (your choice of which sorting algorithm you use to write this method) to sort the values highest to lowest. Write a method to calculate average monthly sales. Write a method to determine the minimum value. Your program should call the sort, average and minimum methods. Create an output file to which you write the sorted array output, the average value and minimum value
Please find the code below::
ProcessMonthlyTickets.java
package fileIO;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ProcessMonthlyTickets {
public static void sort(int numbers[],int size)
{
for(int i=0;i<size;i++){
for(int
j=i+1;j<size;j++){
if(numbers[i]>numbers[j]){
int temp = numbers[i];
numbers[i] =
numbers[j];
numbers[j]= temp;
}
}
}
}
public static double getMonthlyAverage(int
numbers[],int size) {
double avg =0;
for(int i=0;i<size;i++){
avg
+=numbers[i];
}
return avg/size;
}
public static int getMinimum(int numbers[],int
size) {
int minimum =9999;
for(int i=0;i<size;i++){
if(minimum>numbers[i]){
minimum=numbers[i];
}
}
return minimum;
}
public static int readFile(int numbers[]) {
Scanner sc = new
Scanner(System.in);
Scanner reader=null;
while(true){
try {
File file = new File("monthRecord.txt");
reader = new Scanner(file);
break;
} catch
(FileNotFoundException e) {
System.out.println("File not found!!!");
System.exit(0);
}
}
int index=0;
while(reader.hasNextInt()){
try{
numbers[index] =reader.nextInt();
index++;
}catch(Exception
e){
}
}
System.out.println("Successfully
loaded "+index+" monthly report");
return index;
}
public static void main(String[] args) {
int numbers[] = new int[100];
int index =
readFile(numbers);
sort(numbers,index);
System.out.println("\nNumbers in
sorted order is as below");
for(int i=0;i<index;i++){
System.out.println(numbers[i]);
}
System.out.println();
System.out.println("Monthly aveage
is : "+getMonthlyAverage(numbers, index));
System.out.println("Minimum monthly
report is : "+getMinimum(numbers, index));
}
}
output:

monthRecord.txt
1414 1126 1357 1289 1126
In Java step 1) Assume that you have tracked monthly theater movies for 5 months. Save...