Menu

[Solved]Java Already Completed Code Error Inputmismatchexceptions Would Also Like Driver Shorter T Q37232693

java.
This is a already completed code but it has an error(InputMismatchExceptions)
i would also like the driver to be shorter i was told that itstoo long and to “shorten it while still following the rulesbelow”code: https://pastebin.com/fkhAzRwk
Problem:
You are to write a program which will allow users to add to the inventory, and list the books types of books that are collect
- Youll want to store these in an untyped ArrayList. - There will be a menu that will contain at least the following: o AddError i neee fixed:Problems Javadoc B Declaration Console X terminated- BookDetails Java Application] CProgram FilesVavalire 1.8.0 2011binljavaw
Thank you!You are to write a program which will allow users to add to the inventory, and list the books types of books that are collected: cookbooks and magazines. Specifics: in the inventory. There are two – You need to create a book class. Since you’ll be writing the driver, I’m not going to specify what the name of it is, or what the attributes are named. You do need, however, to have a String for the author, ttle, and donor. Also, the value of the book, which is a double. All variables are to be private (and the same rule applies for the subclasses) o Since books don’t change, you don’t need mutators (this applies for both magazine and cookbooks as well). You could argue the value might change, but this organization only keeps books for a year at most, and the value doesn’t change significantly in that time. o You need accessors for these. Cookbook is a subclass. It has two additional attributes, the genre and the number of recipes. o The number of recipes must be greater than 0. o Accessors are needed here. – Magazine is the other subclass. Magazine have a year and a month. o These are both integers. Month will be from 1-12 inclusive o Fun fact: The first magazine was published in 1663, so that will be the minimum value for the year. The aximum value is 2019 o Accessors are needed here as well. – You’l want to store these in an untyped ArrayList. – There will be a menu that will contain at least the following: o Add cookbook o Add magazine o List inventory o Calculate value of inventory o Exit This should be a loop To list the inventory, you wll want to override the toString0 methods, and just call those to get all the information on the books. Whether you only override it in the subclass or in both classes is up to you. New ru Open With Print – You’ll want to store these in an untyped ArrayList. – There will be a menu that will contain at least the following: o Add cookbook o Add magazine o List inventory o Calculate value of inventory o Exit This should be a loop. – To list the inventory, you will want to override the toString0 methods, and just call those to get all the information on the books. Whether you only override it in the subclass or in both classes is up to you New rules: – No default values! Your constructors need to throw exceptions if invalid values are used – Your main program needs to catch these o What it does afterwards is up to you, see below No InputMismatchExceptions! Catch these In short, your program should not crash, ever exception is thrown, you can either request the information again, or simply discard the entry (this is what I advise; it’s easier and the user can type another entry if they wish). But you do need to tell the user something went wrong. Extra credit possibilities abound in this assignment! Think search capabilities… Problems Javadoc B Declaration Console X terminated- BookDetails Java Application] CProgram FilesVavalire 1.8.0 2011binljavaw.exe (Apr 22, 2019 8:35:16 PM) nter option: nter author name: Enter title: Enter publications Enter price: Error: You must enter a numberl Try again: Exception in thread “main” iava.util. InputMi smatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next (Unknown Source) at java.util.Scanner.nextDouble(Unknown Source) at BookDetails.addMagazine (BookDetails.iava:63) at BookDetails.main(BookDetails.iava:193) Show transcribed image text You are to write a program which will allow users to add to the inventory, and list the books types of books that are collected: cookbooks and magazines. Specifics: in the inventory. There are two – You need to create a book class. Since you’ll be writing the driver, I’m not going to specify what the name of it is, or what the attributes are named. You do need, however, to have a String for the author, ttle, and donor. Also, the value of the book, which is a double. All variables are to be private (and the same rule applies for the subclasses) o Since books don’t change, you don’t need mutators (this applies for both magazine and cookbooks as well). You could argue the value might change, but this organization only keeps books for a year at most, and the value doesn’t change significantly in that time. o You need accessors for these. Cookbook is a subclass. It has two additional attributes, the genre and the number of recipes. o The number of recipes must be greater than 0. o Accessors are needed here. – Magazine is the other subclass. Magazine have a year and a month. o These are both integers. Month will be from 1-12 inclusive o Fun fact: The first magazine was published in 1663, so that will be the minimum value for the year. The aximum value is 2019 o Accessors are needed here as well. – You’l want to store these in an untyped ArrayList. – There will be a menu that will contain at least the following: o Add cookbook o Add magazine o List inventory o Calculate value of inventory o Exit This should be a loop To list the inventory, you wll want to override the toString0 methods, and just call those to get all the information on the books. Whether you only override it in the subclass or in both classes is up to you. New ru Open With Print
– You’ll want to store these in an untyped ArrayList. – There will be a menu that will contain at least the following: o Add cookbook o Add magazine o List inventory o Calculate value of inventory o Exit This should be a loop. – To list the inventory, you will want to override the toString0 methods, and just call those to get all the information on the books. Whether you only override it in the subclass or in both classes is up to you New rules: – No default values! Your constructors need to throw exceptions if invalid values are used – Your main program needs to catch these o What it does afterwards is up to you, see below No InputMismatchExceptions! Catch these In short, your program should not crash, ever exception is thrown, you can either request the information again, or simply discard the entry (this is what I advise; it’s easier and the user can type another entry if they wish). But you do need to tell the user something went wrong. Extra credit possibilities abound in this assignment! Think search capabilities…
Problems Javadoc B Declaration Console X terminated- BookDetails Java Application] CProgram FilesVavalire 1.8.0 2011binljavaw.exe (Apr 22, 2019 8:35:16 PM) nter option: nter author name: Enter title: Enter publications Enter price: Error: You must enter a numberl Try again: Exception in thread “main” iava.util. InputMi smatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next (Unknown Source) at java.util.Scanner.nextDouble(Unknown Source) at BookDetails.addMagazine (BookDetails.iava:63) at BookDetails.main(BookDetails.iava:193)

Expert Answer


Answer to java.This is a already completed code but it has an error (InputMismatchExceptions)i would also like the driver to be sh… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *