_MuradPro_

Bookstore

Mar 29th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public class Bookstore {
  2.  
  3.     static Book[] books = new Book[3];
  4.     static int count=0;
  5.    
  6.     public static void main(String[] args) {
  7.  
  8.         books[0] = new Book("Knight-phantom", "Cornelia Funke", 2012, 200);
  9.  
  10.         books[1] = new Book("Harry Potter", "Joanne Rowling", 2019, 300);
  11.  
  12.         books[2] = new Book("Elligent", "Veronica Roth", 2017, 100);
  13.  
  14.         for(int i=0; i<books.length; i++) {
  15.             if(books[i].newBook(2020))
  16.                 count++;
  17.                         System.out.println("The new cost of book number " +(i+1) + " is " + books[i].newPrice(10) );
  18.         }
  19.          
  20.         System.out.println(count + " books are new");
  21.  
  22.     }
  23.        
  24.  
  25.  
  26. }
Add Comment
Please, Sign In to add comment