A store owner keeps a record of daily cash transactions in a text file. Each line contains three items: The invoice number, the cash amount, and the letter P if the amount was paid or R if it was received. Items are separated by spaces. Assume all input files are in this valid format. Write a method balance which takes as parameters the amount of cash at the beginning and end of the day, and the name of the file, checks whether the actual amount of cash at the end of the day equals the expected value, and returns the result as a string. Use this template: BalanceTransactions.java You must catch any FileNotFoundException that is thrown and print out a message in the format: "File: [filename] not found", e.g., File: transactions1.txt not found Example: balance (0, 55.55, "res/transactions1.txt , "); // returns "End of day total is properly balanced." balance (25, 55.55, "res/transactions1.txt "); // returns "End of day total is not balanced." balance (0, 55.55, "res/doesnotexist.txt"); // prints out "File: res/doesnotexist.txt not found"

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java. Please use the template in the picture, thank you!

3 // BalanceTransaction.java
4
50 /**
* A utility class for validating the cash on hand amount at the end of the day with the
* amount recorded in a file
* /
6.
7
8
9.
10 public class BalanceTransactions {
11
120
/**
* Given a starting balance (amount of cash at the beginning of the day) and an
* ending balance (amount of cash at the end of the day), checks whether the
* actual amount of cash at the end of the day equals the expected value (within
an 1E-3 error margin)
13
14
15
*
16
*
17
18
* @param startBalance amount of cash at the beginning of the day; assume always
*
19
>= 0
* @param endBalance
* @param filename
20
amount of cash at the end of the day
21
name of file containing transactions
*
22
23
* @return a string indicating whether the end of day total was balanced or not
(either "End of day total is properly balanced." or "End of day total
is not balanced."
*
24
*
25
26
* /
public static String balance (double startBalance, double endBalance, String filename) {
return ""; // FIX ME
}
270
28
29
30 }
31
Transcribed Image Text:3 // BalanceTransaction.java 4 50 /** * A utility class for validating the cash on hand amount at the end of the day with the * amount recorded in a file * / 6. 7 8 9. 10 public class BalanceTransactions { 11 120 /** * Given a starting balance (amount of cash at the beginning of the day) and an * ending balance (amount of cash at the end of the day), checks whether the * actual amount of cash at the end of the day equals the expected value (within an 1E-3 error margin) 13 14 15 * 16 * 17 18 * @param startBalance amount of cash at the beginning of the day; assume always * 19 >= 0 * @param endBalance * @param filename 20 amount of cash at the end of the day 21 name of file containing transactions * 22 23 * @return a string indicating whether the end of day total was balanced or not (either "End of day total is properly balanced." or "End of day total is not balanced." * 24 * 25 26 * / public static String balance (double startBalance, double endBalance, String filename) { return ""; // FIX ME } 270 28 29 30 } 31
A store owner keeps a record of daily cash transactions in a text file. Each line contains three items: The
invoice number, the cash amount, and the letter P if the amount was paid or R if it was received. Items are
separated by spaces. Assume all input files are in this valid format.
Write a method balance which takes as parameters the amount of cash at the beginning and end of the
day, and the name of the file, checks whether the actual amount of cash at the end of the day equals the
expected value, and returns the result as a string. Use this template: BalanceTransactions.java
You must catch any FileNotFoundException that is thrown and print out a message in the format:
"File: [filename] not found", e.g., File: transactions1.txt not found
Example:
balance (0, 55.55, "res/transactions1.txt , "); // returns "End of day total
is properly balanced."
balance (25, 55.55, "res/transactions1.txt ¿ "); // returns "End of day
total is not balanced."
balance (0, 55.55, "res/doesnotexist.txt"); // prints out "File:
res/doesnotexist.txt not found"
Transcribed Image Text:A store owner keeps a record of daily cash transactions in a text file. Each line contains three items: The invoice number, the cash amount, and the letter P if the amount was paid or R if it was received. Items are separated by spaces. Assume all input files are in this valid format. Write a method balance which takes as parameters the amount of cash at the beginning and end of the day, and the name of the file, checks whether the actual amount of cash at the end of the day equals the expected value, and returns the result as a string. Use this template: BalanceTransactions.java You must catch any FileNotFoundException that is thrown and print out a message in the format: "File: [filename] not found", e.g., File: transactions1.txt not found Example: balance (0, 55.55, "res/transactions1.txt , "); // returns "End of day total is properly balanced." balance (25, 55.55, "res/transactions1.txt ¿ "); // returns "End of day total is not balanced." balance (0, 55.55, "res/doesnotexist.txt"); // prints out "File: res/doesnotexist.txt not found"
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education