COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Arrays ArrayProcessing.java BookRating.java BookRatingWithFileIO.java Book Rating OOP Program
Book.java
BookRatingClient.java
Array of Objects Program
City.java
CityClient.java




BookRatingOOP Program


Description

Use OOP approach to write BookRating program

This program uses an array of Book objects to store book information (title and rating) and uses several methods to do the following:

Determine the number of books in the data file

Fill in the arrays with the data in the data file

Calculate the average rating

Find the book with the highest rating (assume there is no tie)

Print books' title and rating

Associated Concepts:

Array

OOP

File Input / Output

JFileChooser class

Algorithm:

For Book class, the class diagram is represented in UML (Unified Modeling Language) notation.



Client program:

Use JFileChooser object to select the data file

Determine the number of books in the data file

Create an array of Book

Call methods to:

Populate the arrays with data in the data file

Print array elements

Calculate the total rating

Find the index of the book with the highest rating and print the result

Print the average rating

Source Code





Input File BookRating_Data.txt:



Sample Run



Video