Create a program named bookexceptiondemo

Assignment Help Programming Languages
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.

Reference no: EM13781751

Questions Cloud

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.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd