Details of this Paper

C# Exercise5 A and B BookExceptionDemo

Description

solution


Question

Description;a. Create a program named BookExceptionDemo for the Peterman Publishing Company. The company has decided that no published book should cost more than 10 cents per page. Create a BookException class whose constructor re-quires three arguments: a string Book title, a double price, and an int number of pages. Create an error message that is passed to the Exception class constructor for the Message property when a Book does not meet the price-to-pages ratio. For example, an error message might be;For Goodnight Moon, ratio is invalid...Price is $12.99 for 25 pages.;Create a Book class that contains fields for title, author, price, and number of pages. Include properties for each field. Throw a BookException if a client program tries to construct a Book object for which the price is more than 10cents per page. Create a program that creates at least four Book objects - somewhere the ratio is acceptable and others where it is not. Catch any thrown exceptions and display the BookException Message.;b. Using the Book class created in Exercise 5a, write an application named BookExceptionDemo2 that creates an array of five Books. Prompt the user for values for each Book. To handle any exceptions that are thrown because of improper or invalid data entered by the user, set the Book?s price to the maximum 10 cents per page. At the end of the program, display all the entered, and possibly corrected, records.

 

Paper#64027 | Written in 18-Jul-2015

Price : $19
SiteLock