Advertisement
mmayoub

Books with rating over 4

Mar 10th, 2023
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.23 KB | Source Code | 0 0
  1. public static int booksOver4(Book[] books) {
  2.         int count = 0;
  3.  
  4.         for (int i = 0; i < books.length; i++) {
  5.             if (books[i].getRating() > 4) {
  6.                 System.out.println(books[i].getTitle());
  7.                 count++;
  8.             }
  9.         }
  10.  
  11.         return count;
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement