Question: Please help. Access starter source file Billsummary . java and data file energy . txt . The file framework is started for you but the

Please help. Access starter source file Billsummary . java and data file energy . txt. The file
framework is started for you but the file loop, array processing, calculations, and output are
yet to go.
Write a program that summarizes the energy bill for this home. You are provided a data file
containing the month, year, and energy usage for a given month for a three-year period. The
information is randomized. Some example data in the file:
12,2021,1200
7,2023,1490
10,2021,862
,:
Use the method created above to calculate the energy cost for a given month. Then,
summarize the average energy cost per month for that three-year period. Your output could
looks something like:
Be sure to format the resulting dollar amounts to two decimal places.
import java.io.*;
import java.util.Scanner;
public class BillSummary
{
static final String FILENAME = "energy.txt";
public static void main(String[] args)
{
// Start file processing
try
{
String filename = FILENAME;
File dataFileRef = new File(filename);
// Check for file existence. If not found, display error and crash
if (!dataFileRef.exists())
{
System.out.println("File not found");
System.exit(0);
}
Scanner inputFile = new Scanner(dataFileRef);
// File processing loop.
}
catch (IOException e)// If file error, display message and crash
{
System.out.println("File error");
System.exit(0);
}
}
}
 Please help. Access starter source file Billsummary . java and data

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!