Objectives

This assessment item is designed to test your understanding of arrays/arraylists, objects, classes, methods, sorting and searching.

Assessment task

Write a java console application that allows the user to read, validate, store, display, sort and search the title (String), ISBN (integer number), original price (double number) and discounted price (double number) for N books. N should be declared as a constant and it should be equal to the largest digit of your student id number (e.g. if your ID number is S0172341 then N should be equal to 7 and you can declare it as final int N=7;). The book title, ISBN, original price and discounted price must be stored in four separate single dimension Arrays/ArrayLists (index 0 for book 1 and index N-1 for book N). The minimum and maximum ISBN numbers which can be stored are 0 and 999999. The minimum and maximum original prices which can be stored are $10 and $200. The ISBN and original price must be entered from the keyboard and a validation for minimum and maximum values must be done.

Your application should display and execute a menu with the following options. A switch statement must be used to execute the following menu options.

1. Read, validate and store book title, ISBN and original price for N books

2. Calculate, store and display the discounted price (price after 10% discount) for all books

3. Display all ISBN numbers which have over $100 original price

4. Find and display the book title with the lowest original price

5. Find and display the ISBN number with the highest discounted price

6. Sort and display the book titles in ascending order

7. Search and display the accounts which have ISBN equal to the given ISBN

8. Exit from the application

1. Read, validate and store book title, ISBN and original price for N books This option reads book title, ISBN and original price for all books from the keyboard and stores them in three separate single dimension Arrays/ArrayLists. If the ISBN number is less than 0 and greater than 999999 then an appropriate message should be displayed and the user should be asked to enter a new ISBN number. Similarly if the original price is less than $10 and greater than $200 then an appropriate message should be displayed and the user should be asked to enter a new price.

2. Calculate, store and display the discounted price (price after 10% discount) for all books This option calculates the price after 10% discount, stores in an Array/ArrayList and displays the book title, ISBN and discounted price.

3. Display all ISBN numbers which have over $100 original price This option displays all book titles stored in Array/ArrayList which have over $100 original price. If there are no books with over $100 then an appropriate message should be displayed.

4. Find and display the book title with the lowest original price This option finds and displays the book title stored in Array/ArrayList which has the lowest original price.

5. Find and display the ISBN number with the highest discounted price This option finds and displays the ISBN stored in Array/ArrayList which has the highest discounted price. If there is more than one ISBN with the same discounted price then it displays all of them.

6. Sort and display the book titles in ascending order This option sorts and displays the book titles stored in Array/ArrayList for all books in ascending order. You can use any sorting algorithm. A built-in sort algorithm for sorting is not allowed in this assignment.

7. Search and display the accounts which have ISBN equal to the given ISBN This option searches Array/ArrayList and displays the accounts which have ISBN equal to the given ISBN. The application asks the user to enter the ISBN using the keyboard and searches for it. If the ISBN entered from the keyboard is found then the application displays book title, ISBN, original price and discounted price otherwise it displays an appropriate message. A built-in search algorithm for searching can be used in this assignment.

8. Exit from the application The application should display the message Thanks for using the program and your student id number and then exit from the application.

The application should work in a loop to enable the user to Read, validate and store book title, ISBN and original price for N books, Calculate, store and display the discounted price (price after 10% discount) for all books, Display all ISBN numbers which have over $100 original price, Find and display the book title with the lowest original price, Find and display the ISBN number with the highest discounted price, Sort and display the book titles in ascending order, Search and display the accounts which have ISBN equal to the given ISBN and Exit from the application

Program design

You may use any design that meets the specification. However, a good design will adhere to the following guidelines:

  • be logically correct
  • be easy to read and maintain
  • be well-designed
  • use a UML activity diagram
  • use appropriate classes, methods and fields
  • Your design MUST use the classes and methods as listed below.
public class Book
{
//fields
//get and set methods
}

public class BookTest
{
Method to read, validate and store book title, ISBN and original price for N books
Method to calculate, store and display the discounted price for all books
Method to display all ISBN numbers which have over $100 original price
Method to find and display the book title with the lowest original price
Method to find and display the ISBN number with the highest discounted price
Method to sort and display the book titles in ascending order
Method to search and display the accounts which have ISBN equal to the given ISBN
public static void main(String[] args)
{
}
}

You may add/use other methods, parameters, fields/variables, constants, etc. which you need to complete the application.

Testing

Testing is important. You should:

  • List the different types of test cases.
  • Display the results for each test case.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.