Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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 ...

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91606944
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Programming Language

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As