View Single Post
  #1  
Old 11-26-2016, 05:28 PM
Helper Helper is offline
Administrator
 
Join Date: Aug 2016
Posts: 3
Default Java Homework Need Help

Section2 : Exercise User Requirements (exercise.cpp): Your exercise.cpp program will build on the functionality of the exercisea.cpp program. It will ask the user how many books they wish to enter, then let the user enter that many books. The user can enter from 1 to 10 books. You should also add error-checking to the enterBook function to ensure the user enters valid data for each field. Once all the book information is entered, display the information back to the user. Assumptions: ? The $ symbol is not endtered by the user, it is part of the output ? prices must be > 0. Users should be given a warning if they attempt to enter an invalid value, and try again ? ISBN?s should be positive integers ? When outputting the price, format it with 2 values after the decimal, ? You may specify a max price Exception Handling: ? If the user enters a non-numerical value for the isbn, price, or number of books, output an error and let the user try again. The program should let the user try indefinitely until they enter valid input Sample Output: This program let?s the user enter information about a number of books, and output the information back to the user. Please enter a number between 1 and 10: boo sorry, try again Please enter a number between 1 and 10: 2 1: Please enter the book's info: ISBN: 123412341 title: A Book author (lastName, firstName): Smith, Bob price: $5 2: Please enter the book's info: ISBN: 1234567890 title: Another Book author (lastName, firstName): Jane, Mary price: $5.5 These are the books you entered: ISBN: 123412341 Author: Smith, Bob Title: A Book price: $5.00 ISBN: 1234567890 Author: Jane, Mary Title: Another Book price: $5.50 This program let's the user enter information about a number of books, and output the information back to the user. Please enter a number between 1 and 10: 3 1: Please enter the book's info: ISBN: boo Sorry, that was not a number, please try again 12341234 title: book author (lastName, firstName): baggins, bilbo price: $-9 Sorry, that was not a number, please try again 8 2: Please enter the book's info: ISBN: 1234567890 title: geldof, bob author (lastName, firstName): geldof, bob price: $4.56 3: Please enter the book's info: ISBN: 09870987 title: Cat in the Hat author (lastName, firstName): Seuss, Dr. price: $99.90