Reference no: EM13781751
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.
Single-period inventory system
: The restaurant you are working at makes one massive batch of ravioli each day. If you run out before the end of the day, the last few customers are less than satisfied, but if you make too much, it can be sold to the local hog farmer for feed. Every ..
|
Linking motivation and performance
: Describe an instance where you were involved in a situation where you had to strategize in order to lead the group out of a crisis (e.g., at work, as a member of a sports team, debating team, etc.). Evaluate the strategies that you employed to mot..
|
Cross-cultural approaches to leadership development
: Identify some of the pros and cons of arming probation officers. If you were a probation officer, would you want to be required to carry a firearm?
|
Liquid natural gas-what is economic order quantity
: An energy company orders metric tons of liquid natural gas that is used at the rate of 1,000,000 metric tons per year. Delivery lead time has averaged 8 days. The annual cost to hold inventory is $50 per metric ton and each order that is placed with ..
|
Create a program named bookexceptiondemo
: 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..
|
How much profit must be forfeited to fill this order using
: The owner of the Weiner-Meyer meat processing plant wants to determine the best blend of meats to use in the next production run of hamburgers. Three sources of meat can be used. The following table summarizes relevant characteristics of these meats:
|
What are the global challenges of emergency management
: Conduct independent research on that topic, and prepare a 10-12 page paper discussing the topic and its relation to the emergency management field. What are the global challenges of emergency management
|
Assignment on debbie''s dilemma
: Debbie Vestica decided to look for a new job on a day that should have been filled with joy. She had just completed amaster's degree in nursing and had been given a substantial increase in pay, along with new benefits. Other factors,however, great..
|
Set of customs and beliefs
: Cultural relativism asserts that every culture has its own set of customs and beliefs, and that culture must be understood by the standards and values of the people within that culture.
|