0% found this document useful (0 votes)
16 views

R02

Uploaded by

abhaypandeyts04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

R02

Uploaded by

abhaypandeyts04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;
public class R02 {
private String bookName;
private double price;
private String author;
private String type;
private double gst;
private int quantity;

public R02(String bookName, double price, String author, String type, double
gst, int quantity) {
this.bookName = bookName;
this.price = price;
this.author = author;
this.type = type;
this.gst = gst;
this.quantity = quantity;
}

public double getTotalPrice() {


return price + (price * (gst / 100));
}

public double getTotalAmount() {


return getTotalPrice() * quantity;
}

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);

System.out.println("***************************************************************
*****************************************************");
System.out.println("*+++++++++++++++++ Welcome to Library
Book Calculator Program +++++++++++++++++++++*");
System.out.println("*+++++++++++++++++ Thank You For
Choosing This Program +++++++++++++++++++++*");

System.out.println("***************************************************************
*****************************************************");
R02[] books = new R02[50];

for (int i = 0; i < 2; i++) {


System.out.println("Enter details for Book " + (i + 1) + ":");
System.out.print("Book Name: ");
String bookName = scanner.nextLine();
System.out.print("Price: ");
double price = scanner.nextDouble();
scanner.nextLine(); // consume newline left-over
System.out.print("Author: ");
String author = scanner.nextLine();
System.out.print("Type: ");
String type = scanner.nextLine();
System.out.print("GST (%): ");
double gst = scanner.nextDouble();
scanner.nextLine(); // consume newline left-over
System.out.print("Quantity: ");
int quantity = scanner.nextInt();
scanner.nextLine(); // consume newline left-over
books[i] = new R02(bookName, price, author, type, gst, quantity);
}

System.out.println("\nBook Details:");
System.out.println("------------------------------------------------");
System.out.println("Book Name\t\t\t\tPrice\tAuthor\t\t\tType\tGST\
tQuantity\t\tTotal Price\t Amount");
System.out.println("------------------------------------------------");
double totalamount = 0;
for (int i = 0; i < 2; i++) {
System.out.printf("%s\t\t\t\t\t%.2f\t%s\t\t\t%s\t%.2f\t%d\t\t\t%.2f\t\
t\t%.2f%n", books[i].bookName, books[i].price, books[i].author, books[i].type,
books[i].gst, books[i].quantity, books[i].getTotalPrice(),
books[i].getTotalAmount());
totalamount = totalamount + books[i].getTotalAmount();
}
System.out.println("Total Amount : "+totalamount);

System.out.println("===============================================================
========================================================");

System.out.println("***************************************************************
********************************************************");
System.out.println("*============================
==========================*");
System.out.println("* The End Of Library Book
Calculator , Thank you To be with Us *");
System.out.println("*============================
==========================*");

System.out.println("***************************************************************
********************************************************");
}
}

You might also like