Capgemini ADAPT 2022 Sprint 5 Book Rental B  Problem Solution – InvalidQuantity using Java

In this post, we have tried to provide a solution to the problem of Capgemini ADAPT 2022 Sprint 5 Book Rental A  Problem Solution (InvalidQuantity) using JAVA.

Note: The solutions are provided for your reference only. During the assessment, you are requested to not use any malpractices, rather than solve all the problems on your own. We do not encourage candidates to fall into any malpractice.

Book Rental A – S2_JBR-CS-S5-2-InvalidQuantity Problem Solution:

Write a program to create a class BookRental and define setters and getters along with para constructor and toString method as described in the problem statement.

Evaluate the quantity of BookRental for the given input. The constructor and the setter method of BookRental should throw InvalidQuantityException when the quantity is set less than 5 and handle it gracefully by displaying the cause of the abnormality.

Solution of InvalidQuantity:

import java.util.*;

class Book {
int bookId;
String title;
String description;
String author;
double price;
int totalQuantity;
int availableQuantity;
double rentPerDay;

public Book(int bookId, String title, String description, String author,double price,int totalQuantity, int availableQuantity,
double rentPerDay) {
this.bookId = bookId;
this.title = title;
this.description = description;
this.author = author;
this.totalQuantity = totalQuantity;
this.availableQuantity = availableQuantity;
this.price = price;
this.rentPerDay = rentPerDay;
}
public Book() {}
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getTotalQuantity() {
}

public void setTotalQuantity(int totalQuantity) {
this.totalQuantity = totalQuantity;
}
public int getAvailableQuantity() {
return availableQuantity;
}
public void setAvailableQuantity(int availableQuantity) {
this.availableQuantity = availableQuantity;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getRentPerDay() {
return rentPerDay;
}
public void setRentPerDay(double rentPerDay) {
this.rentPerDay = rentPerDay;
}
@Override
public String toString() {
return “Book [bookId=” + bookId + “, title=” + title + “, description=” + description + “, author=” + author+
“, price=” + price+ “, totalQuantity=” + totalQuantity + “, availableQuantity=” + availableQuantity +
“, rentPerDay=” + rentPerDay + “]”;
}
}
String emailId;
String firstName;
super();
this.emailId = emailId;
this.firstName = firstName;
}
}
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
}
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Override
public String toString() {
}
}

Top Companies + Batchwise Hiring Drive:

 TOP COMPANIES HIRING DRIVE BATCHWISE HIRING DRIVES

Capgemini ADAPT Sprint 1 (Bus Reservation Solutions):

• 1. Capgemini ADAPT Sprint 1 Bus Reservation System – DisplayCustomerInAscendingOrder Problem Solution
• 2. Capgemini ADAPT Sprint 1 Bus Reservation System – DisplayCustomerByFirstName Problem Solution
• 3. Capgemini ADAPT Sprint 1 Bus Reservation System – SortByCustomerId Problem Solution
• 4. Capgemini ADAPT Sprint 1 Solution Java | LSAByCustomerName Problem Solution
• 5. Capgemini ADAPT Sprint 1 Case Study Solution Java | BSAByCustomerId Problem Solution

Capgemini ADAPT Sprint 2 (Bus Reservation System):

• 1. Capgemini ADAPT Sprint 2 Case Study (Bus Reservation System) Solution | HAS-A-Relationship Solution Java
• 2. Capgemini ADAPT Sprint 2 Case Study (Bus Reservation System) Solution OOPs-Para-Constructor Java
• 3. Capgemini ADAPT Sprint 2 Bus Reservation System (CRUDOperations) Problem Solution

Online Shopping A Solutions Using Java:

• 1. Capgemini ADAPT 2022 Online Shopping A – Display Products Solution using JAVA – Click Here
• 2. Capgemini ADAPT 2022 Online Shopping A – Products by Category Solution using JAVA – Click Here
• 3. Capgemini ADAPT 2022 Online Shopping A – Customer Array Solution using JAVA – Click Here
• 4. Capgemini ADAPT 2022 Online Shopping A – Search Customers by Name Solution using JAVA – Click Here
• 5. Capgemini ADAPT 2022 Online Shopping A – Search Customers by City Solution using JAVA – Click Here
• 6. Online Shopping A – Customer & Rentress Class Solution | Capgemini ADAPT 2022 Solutions – Click Here

Job Seeker 24 provides Off-Campus Drive Updates, Engineering Job Updates, IT Job Updates, Jobs for Freshers, Private Sector Jobs, Public Sector Jobs, various Educational Opportunities, etc.