import java.util.Scanner;
public class Book {
private String title;
private String author;
private double cost;
public Book() {
this.title = "";
this.author = "";
this.cost = 0.0;
}
public void setTitle(String title) {
this.title = title;
}
public void setAuthor(String author) {
this.author = author;
}
public void setCost(double cost) {
this.cost = cost;
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public double getCost() {
return cost;
}
public void readInput() {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the book title: ");
setTitle(scanner.nextLine());
System.out.print("Enter the author's name: ");
setAuthor(scanner.nextLine());
System.out.print("Enter the cost of the book: ");
setCost(scanner.nextDouble());
}
public double salePrice(double discount) {
return cost - (cost * (discount / 100));
}
public void writeOutput() {
System.out.println("Title: " + title);
printAuthorInTriangle();
System.out.println("Cost: " + cost);
}
private void printAuthorInTriangle() {
for (int i = 0; i < author.length(); i++) {
for (int j = 0; j <= i; j++) {
System.out.print(author.charAt(i));
}
System.out.println();
}
}
public static void main(String[] args) {
Book book = new Book();
book.readInput();
book.writeOutput();
System.out.println("Sale Price: " + book.salePrice(10));
}
}