Problem 1 and 2: TextImprover (20 pts)There are some words that people tend to overuse when writing documents, such as "amazing," "literally," "actually," "absolutely," etc. For this problem, you will...

2 answer below ยป




Problem 1 and 2: TextImprover (20 pts)





There are some words that people tend to overuse when writing documents, such as "amazing," "literally," "actually," "absolutely," etc. For this problem, you will implement a class that searches for overused words and replaces them with better choices.


Implement a classTextImproverthat provides a method for improving the text in a text file (let's call it the "input file") by replacing overused words with better choices of words, based on another text file (let's call it "word map") that maps overused words to non-overused words.


Use this template:
TextImprover.java


Download TextImprover.java



A few notes:




  • Assume the words in the word map will always be in all lower case and consist of only letters.


  • TextImprovermust preserve word case. But you can assume all words in the input file are either in all lower case, leading upper case, or all caps.


  • Assume every word in the input file consists of at least one letter and also include punctuation characters, and there is exactly one space in between each word in a line.


  • TextImprovermust preserve the punctuation of the input file.

  • You must catch anyFileNotFoundException
    that is thrown and print out a message in the format: "File: [filename] not found", e.g.,
    File: overused1.txt not found













Example:









// all examples use
overused-words.txt


Download overused-words.txt

as the file containing overused words and their replacements


TextImprover ti = new TextImprover("overused-words.txt");








// overused1.txt starts out like this:
overused1.txt


Download overused1.txt












ti.improveText("overused1.txt");








// overused1.txt now looks like this:
overused1-after.txt


Download overused1-after.txt


























Problem 3: Student (10 pts)








Given aStudentclass (
Student.java


Download Student.java

), modify the class to throw anIllegalArgumentExceptionunder the following two conditions:






  1. The account is constructed with a negative student ID (exception message: "ID cannot be negative")




  2. An attempt is made to drop a class in which the student is not enrolled (exception message: "Cannot drop class [CLASSNAME] because student is not enrolled in it")














Example:


try {
Student george = new Student("George Glass", -1234);
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}








// The above prints out "ID cannot be negative"
Student robert = new Student("Robert Navarro", 1234);
robert.addClass("ICS 45J");
robert.addClass("Ballet I");
robert.addClass("Chem 51C");



try {
robert.dropClass("ICS 10");
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}







// The above prints out "Cannot drop class ICS 10 because student is not enrolled in it"














Problem 4: Product and ProductDB(10 pts)









Robert recently went into business for himself with a pet store! However, he spends so much time sleeping on his couch that he is unaware of modern technology. So in his store, they keep all the data about their products in a text file.




Each line in this text file contains the following, separated by semicolons:





  • The name of the product




  • The price of the product




  • The quantity of product





Sample file here:
products.txt


Download products.txt







Implement a classProductthat is represented by a name, price, and quantity. Use this template:
Product.java


Download Product.java







Also implement a classProductDBthat reads in data from a text file and provides methods for searching and adding products. Use this template:
ProductDB.java


Download ProductDB.java










You must catch anyFileNotFoundExceptionthat is thrown and print out a message in the format: "File: [filename] not found", e.g.,File: products1.txt not found





Example:


ProductDB db = new ProductDB("
products.txt


Download products.txt

");
db.findProduct("Blue plaid bow tie collar"); // returns the product "Blue plaid bow tie collar" with price 29.95 and quantity 6
db.findProduct("Red bandana"); // returns the product "Red bandana" with price 3.99 and quantity 16
db.findProduct("White porcelain food and water bowl set"); // returns the product "White porcelain food and water bowl set" with price 23.00 and quantity 8
db.findProduct("XL tan fluffy dog bed"); // returns the product "XL tan fluffy dog bed" with price 75.25 and quantity 2
db.findProduct("stuffed sloth"); // returns null
db.addProduct("stuffed sloth", 9.99, 4);
db.findProduct("stuffed sloth"); // returns the product "stuffed sloth" with price 9.99 and quantity 4
db.addProduct("stuffed sloth", 10.99, 16);
db.addProduct("stuffed sloth", 0.99, 1);
db.findProduct("stuffed sloth"); // returns the product "stuffed sloth" with price 9.99 and quantity 4
// products.txt now looks like this:
products-after.txt


Download products-after.txt












Problem 5: BankAccount and Bank (10 pts)







Implement a classBankAccountthat is represented with an account number and balance. Use this template:
BankAccount.java


Download BankAccount.java
















Also implement a classBankthat contains a number of bank accounts, read from a file, and provides a method for returning the account with the lowest balance. Use this template:
Bank.java


Download Bank.java









TheBankclass must read a file with the format of these sample files:
accounts1.dat


Download accounts1.dat



accounts2.dat


Download accounts2.dat



accounts3.dat


Download accounts3.dat



accounts4.dat


Download accounts4.dat









Namely, the format is:






accountNumber1 balance1


accountNumber2 balance2


. . .

You can assume that all input files are in the correct format.


You must catch anyFileNotFoundExceptionthat is thrown and print out a message in the format: "File: [filename] not found", e.g.,File: accounts1.dat not found


Example:


Bank bank = new Bank();







bank.readFile("accounts1.dat");






bank.getLowestBalanceAccount(); // returns account #2






bank.readFile("accounts2.dat");






bank.getLowestBalanceAccount(); // returns account #4








Part B:














Problems 6-10: Email (50 pts)







Implement a simple e-mail messaging system. A message has a recipient, a sender, and a message text. A mailbox can store messages. Each user has a mailbox.




Your program will take four commands: Log in, log out, send, read, and quit. When logging in, the program will ask for just a username. When asking to send a message, the program will ask for the recipient's username and the test of the message. When asking to read messages, the system will display all of the user's messages.




The driver / user interface class for the email system, EmailUI, has already been implemented as is given here:


EmailUI.java


Download EmailUI.java



. Your task is to implement the Message, Mailbox, and MessagingSystem classes, using these templates:

Message.java



Download Message.java

,

Mailbox.java


Download Mailbox.java


,

MessagingSystem.java


Download MessagingSystem.java

.
Notice the templates have more details about each class.















Example:












Answered 5 days AfterNov 04, 2022

Answer To: Problem 1 and 2: TextImprover (20 pts)There are some words that people tend to overuse when writing...

Robert answered on Nov 09 2022
42 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here