CS 219 Unit 6 Chapter 15 Assignment

CS 219 Unit 6 Chapter 15 Assignment

Author: willi padro


Grading Information: This Program is due on Date Specified.Comments are REQUIRED; flow charts and pseudocode are NOT REQUIRED.Directions PointsThe files must be called <LiFiUnit6Ch15.java>LiFiSaleCheck.java (Sale Checker Class File)The files must be called as specified above, (LiFi = Your Last Initial Your First Initial)Proper coding conventions required the first letter of the class start with a capitalletter and the first letter of each additional word start with a capital letter.Only submit the .java files needed to make the program run. Do not submit the.class files or any other files.5%Style ComponentsInclude properly formatted prologue, comments, indenting, and other style elementsas shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.5%Topics covered in chapterTopics with * are covered in this assignment. Ensure you use every item listed below in yourcompleted assignment.*Exceptions and Exception Messages*try / catch*checked and unchecked exceptions*generic catch block*throwsBasic RequirementsWrite a program that validates a sale in dollars and cents with a $ and a .(period).See sample output below.20%LiFiUnit6Ch15.java• Driver class should loop until “q” is entered to quit• If enter is not “q”, then create an instance of the LiFiSaleCheck object passingthe entry as an argument• If no error20% o Print amount by calling: print numeric from LiFiSaleCheck class print alphabetic from LiFiSaleCheck class• If erroro Call the getError() method on this LiFiSaleCheck object and print theerror message (see sample)LiFiSaleCheck.java classSales object should store the sale in 2 integer instance variables, dollars and cents,and include a string variable to hold the error. This should be initialized with null.LiFiSaleCheck Constructor:• Receive sale as a string• Perform error checking to ensure amount was entered in proper format toinclude a period (.) between the dollars and cents and a $ at the start of thestring.• Use indexOf and substring to separate the sale string into the appropriateinstance variables• Use try/catch to catch format errors of dollars and cents as shown in example• If an error occurs, change the error instance variable to reflect the error (seesample)• If more than one error occurs in the format of the dollars and cents, show both.print numeric method:• Print in the format $123.45 using both dollars and cents instance variables (ifamounts like $4.2 is entered, should print $4.20)print alphabetic method:• Print in the format 123 dollars and 45 cents using both dollars and centsinstance variables (if amounts like $4.2 is entered, should print 4 dollars and20 cents)getError method:• returns the error instance variable (String type)50%NOTE: Complete your activity and submit it by clicking “Submit Assignment”Total Percentage 100%SampleYour output will vary based on input.

See More
Try a College Course Free

Sophia’s self-paced online courses are a great way to save time and money as you earn credits eligible for transfer to over 2,000 colleges and universities.*

Begin Free Trial
No credit card required

26 Sophia partners guarantee credit transfer.

226 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 21 of Sophia’s online courses. More than 2,000 colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.