Expalin how to make a bookexception class

Assignment Help Computer Engineering
Reference no: EM1332184

A book publisher has limited the cost of every book they publish to no more than 10 cents per page.

[A] Create a BookException class (in C-Sharp) with a constructor that requires three (3) arguments for each book: a string 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. The error message might be like:

For Goodnight Moon, ratio is invalid.
...Price is $12.99 for 25 pages

The price-to-pages ratio is determined by checking the following: price > RATE * pages where RATE = 0.10

Create a Book class that has the following fields: string title, string author, double price and int number of pages. Throw a BookException if a book object is created that has a price that is more than 10 cents per page.

For testing, create 4 Book objects and use the constructor for Book to pass the four inputs when each object is instantiated, some where the ratio is correct and some where the ratio is not correct. Catch any thrown exceptions and display BookException Message.

For example, if the inputs passed were:

("Goodnight Moon", "Brown", 12.99, 25)
("World History", "Stein", 72.99, 900)
("The Grapes of Math", "Stoltz", 30.99, 300)
("Steal This Book", "Hoffman", 72.99, 800)

the possible output could be:

For Goodnight Moon, ratio is invalid.
...Price is $12.99 for 25 pages.
For The Grapes of Math, ratio is invalid.
...Price is $30.99 for 300 pages.
Press any key to continue . . .

[B] Using the Book class created above, create an application that creates an array of five Book objects, and prompt the user for input values for each Book instead of setting the values with constructors.

To handle any exceptions that are thrown because of improper or invalid data entered by the user, set the Book's price to a maximum 10 cents per page.

At the end of the program display all the entered, and possibly corrected, records.

Possible inputs/output could look like:

Enter title Book 1
Enter author Author 1
Enter price 33.33
Enter pages 333
For Book 1, ratio is invalid.
...Price is $33.33 for 333 pages.
Enter title Book 2
Enter author Author 2
Enter price 22.22
Enter pages 333
Enter title Book 3
Enter author Author 3
Enter price 45.00
Enter pages 200
For Book 3, ratio is invalid.
...Price is $45.00 for 200 pages.
Enter title Book 4
Enter author Author 4
Enter price 25.00
Enter pages 1000
Enter title Book 5
Enter author Author 5
Enter price 30.00
Enter pages 850
Book 1 by Author 1 Price $33.30 333 pages.
Book 2 by Author 2 Price $22.22 333 pages.
Book 3 by Author 3 Price $20.00 200 pages.
Book 4 by Author 4 Price $25.00 1000 pages.
Book 5 by Author 5 Price $30.00 850 pages.
Press any key to continue . . .

Other possible errors might be entered as shown below:

Enter title Book 1
Enter author Author 1
Enter price 33.xx
Input string was not in a correct format.
Enter title Book 1
Enter author Author 1
Enter price 33.33
Enter pages xx.33
Input string was not in a correct format.
Enter title ...

Reference no: EM1332184

Questions Cloud

Discounted payback method-true aand false : Which one of the following statements regarding the discounted payback method is true?
Automating the hr function and hris : Analysis and Recommendations: Automating the HR Function and HRIS - Analysis: After reviewing the scenario below, how might you analyze the current situation and how would you share your analysis with this customer
Elucidate that the indirect utility fuction : Elucidate that the indirect utility fuction of quasi convex function of prices and income
Case on oil exploration : A local energy provider offers a landowner USD 180,000 for the exploration rights to natural gas on a certain site and the option for future development.
Expalin how to make a bookexception class : generate 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.
Mcq question discounted cash flows model : Fixed costs that change for activity outside relevant range would include-When gross margin pricing is employed, the markup percentage includes
Provide separate arguments to support your claims : Provide separate arguments to support your claims as to their slope, curvature, and the direction of increasing utility.
Effect of global cultures-differences and communication : What kind of verbal and nonverbal communication might be used in international corporations and What are the strengths and weaknesses of each type of communication and How does culture affect each type of communication
Make a windows form program for a nina''s cookie source : contain at least one other functional control such as a button (Exit button) or a MenuStrip having an Exit and an About selection.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What are the characteristics of application

offer examples of business applications that exhibit these characteristics. You can provide examples of applications from any client/server development environment. The two main platforms are Microsoft .NET and Sun JAVA J2EE.

  Prepare an analysis discussing the factors

While there is backward compatibility between the various versions of the software, the older versions do not have all of the "bells and whistles" of the newer versions.

  Issues or problems related to database architecture

In a Microsoft Word document, write an 800- to 1,000-word research paper. Your research paper should contain the following sections.

  Build a class hugeinteger which uses a 40-element array

make a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digits each. Provide methods input, output, add and subtract.

  Define the context in which normalization is used

define the context in which Normalization is used. What is its purpose.

  Create a function definition called addarray

Write down a function definition called addarray that takes two parameters- one an array as an int and the other an int that contains the number of elements of the array. The function would return the sum of the number of elements of the array as ..

  Security policy document project

Analyze security requirements and develop a security policy

  Algorithm to prepare a job applicant report

Develop an algorithm in order to prepare a job applicant report. Input consists of a series of records that contain the Social Security number or equivalent, last name, first name, middle initial, verbal test score, science test score, math test s..

  Give solutions of both mobile and server communications

What security suggestions do you have for laptop users to securely access network resources, and to secure files on their laptops.

  Contain reference slide with citations in apa format

build a 5- to 7-slide Microsoft?PowerPoint?presentation detailing the evolution of programming languages. Organize your slide presentation in the form of a timeline, and discuss the various generations of programming language.

  When an entity has the relationship to itself

The presence of one or more foreign keys in a relation prevents. When an entity has a relationship to itself, we have a?

  Find out the minimum-cost spanning trees

Find out the shortest paths from S to all the other nodes in the graph using Dijkstra Algorithm.

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