Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 threeyear period. The
information is randomized. Some example data in the file:
:
Use the method created above to calculate the energy cost for a given month. Then,
summarize the average energy cost per month for that threeyear 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 mainString args
Start file processing
try
String filename FILENAME;
File dataFileRef new Filefilename;
Check for file existence. If not found, display error and crash
if dataFileRef.exists
System.out.printlnFile not found";
System.exit;
Scanner inputFile new ScannerdataFileRef;
File processing loop.
catch IOException e If file error, display message and crash
System.out.printlnFile error";
System.exit;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started