Problem: My problem is I can't get the output of discountRate of this code ,I am giving here the code , please solve just DiscountRate problem output.
Problem: My problem is I can't get the output of discountRate of this code ,I am giving here the code , please solve just DiscountRate problem output.
Start.java
import java.lang.*;
import java.util.Scanner;
public class Start {
public static void main(String[] args) {
{
StoryBook sb1 = new StoryBook ();
sb1.setIsbn("7th Edition");
sb1.setBookTitle("OOP JAVA");
sb1.setAuthorName("RM");
sb1.setPrice(25000.0);
sb1.setAvailableQuantity(20);
sb1.sellQuantity(3);
sb1.addQuantity(5);
StoryBook.discountRate(25.00);
System.out.println("ISBN : " + sb1.getIsbn());
System.out.println("BOOKTITLE : " + sb1.getBookTitle());
System.out.println("AUTHORNAME : " + sb1.getAuthorName());
System.out.println("PRICE : " + sb1.getPrice());
System.out.println("AVAILABLE QUANTITY : " + sb1.getAvailableQuantity());
System.out.println("Discount Rate : " + StoryBook.getDiscountRate());
}
}
}
StoryBook.java
import java.lang.*;
public class StoryBook {
static double discountRate;
String isbn, bookTitle, authorName, category;
int availableQuantity;
double price;
StoryBook() {
this.isbn = "";
this.bookTitle = "";
this.authorName = "";
this.availableQuantity = 0;
this.category = "";
this.price = 0.0;
}
StoryBook(String isbn, String bookTitle, String authorName, double price, int availableQuantity, String category) {
this.isbn = isbn;
this.bookTitle = bookTitle;
this.authorName = authorName;
this.price = price;
this.availableQuantity = availableQuantity;
this.category = category;
}
static void setDiscountRate(double rate) {
discountRate = rate;
}
static double getDiscountRate() {
return discountRate;
}
void setIsbn(String isbn) {
this.isbn = isbn;
}
void setBookTitle(String bookTitle) {
this.bookTitle = bookTitle;
}
void setAuthorName(String authorName) {
this.authorName = authorName;
}
void setPrice(double price) {
this.price = price;
}
void setAvailableQuantity(int availableQuantity) {
this.availableQuantity = availableQuantity;
}
void setCategory(String category) {
this.category = category;
}
String getIsbn() {
return this.isbn;
}
String getBookTitle() {
return this.bookTitle;
}
String getAuthorName() {
return this.authorName;
}
double getPrice() {
return this.price;
}
int getAvailableQuantity() {
return this.availableQuantity;
}
String getCategory() {
return this.category;
}
public void addQuantity(int amount)
{
if(amount>0)
{
availableQuantity = availableQuantity + amount;
}
else
{
System.out.println("Invalid");
}
}
public void sellQuantity(int amount)
{
if(amount>0 && amount<=availableQuantity)
{
availableQuantity = availableQuantity - amount;
}
else
{
System.out.println("Invalid");
}
}
void showDetails() {
System.out.println("ISBN : " + getIsbn());
System.out.println("Book Title : " + getBookTitle());
System.out.println("Author Name : " + getAuthorName());
System.out.println("Price : " + getPrice());
System.out.println("Category : " + getCategory());
System.out.println("Available Quantity : " + getAvailableQuantity());
System.out.println("Discount Rate : " + StoryBook.getDiscountRate());
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images