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

  Create a very simple four function integer calculator

Create a very simple four function integer calculator with buttons for Add, Subtract, Multiply, and Divide, and with two text-type input fields. When the user enters two numbers and clicks one of the buttons, the answer is displayed where shown.

  Designing navigation system for point-and-click system

Design a navigation system or menu allows Access to act like point-and-click system. Write down some of the kinds of navigation.

  Write program to prompt user to enter string of caharacter

Write a program that prompts the user to enter a string of 87 characters the program should display the middle character in the string if there is an odd number characters in the string.

  Implement two different versions of file copy utility

You will implement two different versions of file copy utility, one by using read()/write() operations and one by using mmap(). You are only prmitted to use following system calls:

  Calculate and print the annual salary of the employee

Calculate and print the annual salary of the employee. suppose employee receive 6% increase in pay. Calculate and print net pay giving the pay rate and hours work. Suppose deductions amount to 9% of the gross pay.

  Write program that merges two files

The first programming project involves writing a program that merges two files that contain polynomials. To merge two files, the input files must be in sorted order.

  Write a recursive-descent parser

Use any programming language you prefer to write a recursive-descent parser that parses the language generated by the following EBNF descriptions.

  Php script to obtain url and its description from user

Write a PHP script to obtain URL and its description from user and stores information into database by using MySQL.

  Create program to sum all integers between one and n

Using C++ create program to sum all integers between 1 and n where n is input by keyboard. Print "The sum of all integers from 1 to n is SUM

  Write a program to read student data from standard input

Write a program to read student data from standard input, sort it by last name / first name, and print result to standard output.

  Write program to prompt user to enter year-find leap year

Write down program to prompt the user to enter year, and then tells user whether it is leap year. If user doesn't enter valid year (i.e., a positive integer).

  Create uml collaboration diagrams by using microsoft visio

Create UML collaboration diagrams by using Microsoft Visio or another drawing tool capable of preparing properly formatted UML collaboration diagrams.

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