Write a java program that reads a given data file called tickets that consists of tickets and the ticket prices. Your program should read the data and compute the find minimum, maximum and average ticket prices and output the report into a file called output.txt. The report file should look exactly (or better than) the one shown below.
Your program should implement the Java ArrayList class, Java File I/O, and Java error handling exception.
Below is the content of the output.txt file:
******************************************* TICKET REPORT
******************************************* There are 6 tickets in the database.
Maximum Ticket price is $179.99.
Minimum Ticket price is $49.99.
Average Ticket Price is $XXX.XX.
Thank you for using our ticket system! *******************************************
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// tickets.txt (Input file)
121.45 134.65 179.99 49.99 78.99 67.88
==================================
// Tickets.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Tickets {
public static void main(String[] args) throws
IOException {
int cnt=0;
// DecimalFormat class is used to format the
output
DecimalFormat df = new
DecimalFormat(".00");
double
min=Integer.MAX_VALUE,max=Integer.MIN_VALUE,avg,value,sum=0;
FileWriter fw=null;
Scanner sc=null;
try {
sc=new
Scanner(new File("tickets.txt"));
fw=new
FileWriter(new File("output.txt"));
while(sc.hasNext())
{
value=sc.nextDouble();
cnt++;
if(max<value)
{
max=value;
}
if(min>value)
{
min=value;
}
sum+=value;
}
avg=sum/cnt;
fw.write("*******************************************\n");
fw.write("\t\tTICKET REPORT\n");
fw.write("*******************************************\n");
fw.write("Maximum Ticket price is $"+max+".\n");
fw.write("Minimum Ticket price is $"+min+".\n");
fw.write("Average Ticket Price is $"+df.format(avg)+".\n");
fw.write("Thank you for using our ticket system!\n");
fw.write("*******************************************\n");
} catch (FileNotFoundException e)
{
System.out.println(e);
}
finally
{
if(sc!=null)
{
sc.close();
}
if(fw!=null)
{
fw.close();
}
}
}
}
=====================================
Output.txt (output file)

=====================Could you plz rate me well.Thank You
Write a java program that reads a given data file called tickets that consists of tickets...
I need help writing python code with following instructions. You will write a program that reads a data file. The data file contains ticket IDs and ticket prices. Your job is to read these tickets (and prices). find minimum, maximum and average ticket prices and output a report file. The report file should look exactly (or better than) the one attached (output.txt). Input: A31 149.99 B31 49.99 A41 179.99 F31 169.99 A35 179.99 A44 169.99 open "input.txt" file using open()...
How to write a Java program that reads the file "input.txt" and writes all even values from this file into a new file called "output.txt." Sample input 10 12 1 3 5 34 2 5 7 9 44
Write a program that loads a file called "sample.txt" in read mode, reads its content, and closes the file. Use exception handling to catch any errors. 2. Compute the letter and punctuation distribution in the file. That is, output the number of a’s, the number of b’s, etc. and the number of commas, dashes, and periods. Ignore case when computing this, so ‘A’ and ‘a’ are the same letter. Use lists. 3. Compute the number of words in the file....
Write a Java program in Eclipse that reads from a file, does some clean up, and then writes the “cleaned” data to an output file. Create a class called FoodItem. This class should have the following: A field for the item’s description. A field for the item’s price. A field for the item’s expiration date. A constructor to initialize the item’s fields to specified values. Getters (Accessors) for each field. This class should implement the Comparable interface so that food...
Description: Create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the name of file, sum of numbers, count of numbers, average of numbers, maximum value, minimum value, and range of values. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information. Requirements: Create a program called numstat.py that reads a series of integer numbers from a file and determines...
1. Write a program called Numbers that a. prompts the user for a file name. b. reads that file assuming that its contents consist entirely of integers. c. prints the maximum, minimum, sum, count (number of integers in the file), and average of the numbers. For example, if the file numberinput.dat has the following content: 4 -2 18 15 31 27 Your program should produce the following output: csc% java Numbers Enter file name: numberinput.daft Maximum31 Minimum- -2 Sum -...
Java programming: Write a program called Distribution that reads a file of double values into an array and computes and prints the percentage of those numbers within 1 standard deviation (SD), within 2 SDs, and within 3 SDs of the mean. The program should be modular and should at least contain the main method and a method for computing the above percentages given the numbers, the mean, and the standard deviation. Other required statistics should be computed in their own...
Write a program in Java that reads the file and does two things: Write to an output file called dataSwitch.txt the same data from the input file, but switch the order of the data entries on each line. For example, if the first line of the input file is “90001 57110”, the first line of the output file would be “57110 90001”. Additionally, print to the screen the number of lines in the file with a label
Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...
Problem Definition Write a program called process_ages that reads in an array of up to 10 integers representing peoples ages in years and calculates and prints the maximum age and the minimum age and the average age. Your program should stop reading when either the 10th number is entered or the user enters -1. If the user enters any other negative number or a value above 150, they should be warned and prompted again for a valid age. You should...