## Exercise 5

### Primitive data types

Exercise 5A

Implement a class `Bookstore` for representing bookstores having books in two languages: italian and german. Each `Bookstore` object should maintain the following information:

• the number of books in italian language;
• the number of books in german language.

The `Bookstore` class should export to its clients the following methods:

• A constructor to create a `Bookstore` object with a given initial number of books. The constructor has two parameters: one indicates the initial number of books in italian language, another the initial number of books in german language.
• `addBookI`, which takes one parameter of type `int` and increases the number of books in italian language by its value.
• `addBookG`, which takes one parameter of type `int` and increases the number of books in german language by its value.
• `getOverallBooksNumber`, which returns the total number of books (both in italian and german language) stored in a bookstore.
• `getPercentageOfBooksI`, which returns the percentage of books in italian language. The required percentage is a real number (i.e. `float`) and is equal to:

100.0 * number_of_books_in_italian_language / overall_number_of_books

• `getPercentageOfBooksG`, which returns the percentage of books in german language. The required percentage is a real number (i.e. `float`) and is equal to:

100.0 * number_of_books_in_german_language / overall_number_of_books

Finally, implement a client class which:

• Reads from the keyboard the initial number of books in italian language, and the number of books in german language
• Creates a `Bookstore` object with a given initial number of books.
• Reads from the keyboard an additional number of books in italian language and updates the object with its value.
• Reads from the keyboard an additional number of books in german language and updates the object with its value.
• Prints the percentage of books in italian language.
• Prints the percentage of books in german language.

Exercise 5B

Plan and implement a class `Car` with the following properties:

• `licensePlate` is a string holding the car's license number;
• `mileage` is an integer holding the car's total covered distance in km;
• `acquisitionYear` is an integer holding the year the car was first bought;
• `basePrice` is a double holding the car's base price when it was first bought;
• `owner` is the current car's owner.

The class `Car` should define the following methods:

• the constructor: it takes the license number, the acquisition year and the base price as parameters and sets `mileage` to `0` and `owner` to `null`;
• so called "getters": i.e. methods for all attributes that return the field's value;
• a method `addToMileage` that increments `mileage` by an integer value, passed as parameter;
• a method `setOwner` that sets the `owner` field to a string value, passed as parameter.

Furthermore, design and implement a client class with a static method `getCurrentValue` that computes the car's current value, given a car object and the current year. Use the equation:

currentValue = basePrice * 0.8 ^ (currentYear - acquisitionYear)

where "a ^ b" means "a to the power b". Use the `pow` method from the `java.lang.Math` package.

Solution