
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

In the old days (when dinosaurs roamed the earth and professors were young), before debit cards, people often wrote checks to pay for purchases. To track your current balance, you recorded your purchases and deposits in a checkbook register, which had columns for the item (check number or deposit), date, transaction (the recipient of the check), and the amount.
Included with the lab is a file named checkbook.txt, which represents a checkbook register:
deposit:July 7:-:300. 416:July 8:Albertsons:15. 417:7/9:Checker Auto:19. 418:7/10:Super Target:47. 419:Dec 5:Home Depot:47.
By default, scanners use white space to separate tokens. However, the columns or fields in the checkbook input file are separated by colons (‘:’). This allows tokens to contain spaces (e.g., “Super Target”). The Scanner class provides a method named useDelimiter to change the default delimiters. For example, if the Scanner object is named “input,” then include the statement: input.useDelimiter(":|\r\n"); The item column distinguishes a deposit from a check by using the word “deposit” for the former and the check number for the latter. A dash (‘-’) appears in the transaction column for a deposit.
You may find it helpful to review table 4.5, p. 241.
Write a Java program named CheckBook.java that does the following:
deposit July 7 300. 416 July 8 Albertsons 15. 417 7/9 Checker Auto 19. 418 7/10 Super Target 47. 419 Dec 5 Home Depot 47.
Balance 168.