Write a program for the management of a bookstore in Java Programming Language, WITHOUT THE USE OF STUFF RELATING TO OBJECTS AND WHAT NOT, just arrays, strings, loops, etc. I'm in an intro to programming class so I haven't learned those techniques and am not allowed to use them.
The books we just create
Overview; Opening menu
1. List all books
2. Search all books
3. Purchase books
4. Exit
If option 1 is chosen: List all books by Title, Author, Price, Copies, Category within a group of arrays
If option 2 is chosen: Search for a specific book - Search by title, Search by author, Search by price, etc
If option 3 is chosen: List books, List shopping cart (current selected books), If book has zero copies display "This book is not in stock", otherwise Update shopping cart and display "Pay to complete the purchase", update book list
If option 4 is chosen: terminate program
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
// Book.java
public class Book {
private String title;
private String author;
private String category;
private double price;
private int noOfCopies;
/**
* @param title
* @param author
* @param category
* @param price
* @param noOfCopies
*/
public Book(String title, String author, String
category, double price,
int noOfCopies)
{
this.title = title;
this.author = author;
this.category = category;
this.price = price;
this.noOfCopies = noOfCopies;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title
* the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the author
*/
public String getAuthor() {
return author;
}
/**
* @param author
* the author to set
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* @return the category
*/
public String getCategory() {
return category;
}
/**
* @param category
* the category to set
*/
public void setCategory(String category) {
this.category = category;
}
/**
* @return the price
*/
public double getPrice() {
return price;
}
/**
* @param price
* the price to set
*/
public void setPrice(double price) {
this.price = price;
}
/**
* @return the noOfCopies
*/
public int getNoOfCopies() {
return noOfCopies;
}
/**
* @param noOfCopies
* the noOfCopies to set
*/
public void setNoOfCopies(int noOfCopies) {
this.noOfCopies = noOfCopies;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return title + " " + author + " " +
category + " $" + price + " "+ noOfCopies;
}
}
___________________________
// BookStore.java
import java.util.Scanner;
public class BookStore {
private Book books[] = null;
private int cnt = 0;
/**
* @param books
* @param cnt
*/
public BookStore() {
this.books = new Book[100];
this.cnt = 0;
}
public void addBook(Book b)
{
if(books.length!=cnt)
{
books[cnt]=b;
cnt++;
}
}
public void listAllBooks()
{
for(int i=0;i<cnt;i++)
{
System.out.println(books[i]);
}
}
public void searchBook()
{
int choice;
int indx=-1;
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
System.out.println("\n1.Keyword in
a book title");
System.out.println("2.author");
System.out.println("3.book
category");
System.out.print("Enter
Chocie:");
choice=sc.nextInt();
sc.nextLine();
switch(choice)
{
case 1:{
System.out.print("Enter keyword in title :");
String
keyword=sc.next();
for(int
i=0;i<cnt;i++)
{
if(books[i].getTitle().contains(keyword))
{
indx=i;
}
}
if(indx==-1)
{
System.out.println("** Book not found
**");
}
else
{
System.out.println(books[indx]);
}
break;
}
case 2:{
System.out.print("Enter author name :");
String
author=sc.nextLine();
for(int
i=0;i<cnt;i++)
{
if(books[i].getAuthor().equalsIgnoreCase(author))
{
indx=i;
}
}
if(indx==-1)
{
System.out.println("** Book not found
**");
}
else
{
System.out.println(books[indx]);
}
break;
}
case 3:{
System.out.print("Enter book category :");
String
category=sc.next();
for(int
i=0;i<cnt;i++)
{
if(books[i].getCategory().equalsIgnoreCase(category))
{
indx=i;
}
}
if(indx==-1)
{
System.out.println("** Book not found
**");
}
else
{
System.out.println(books[indx]);
}
break;
}
default:{
System.out.println("** Invalid Choice **");
break;
}
}
}
public void purchaseBooks()
{
double tot=0;
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
int shopCount=0;
int index=0;
Book shoppingCart[]=new
Book[10];
while(true)
{
for(int
i=0;i<cnt;i++)
{
System.out.println((i+1)+" "+books[i]);
}
System.out.print("Enter Index of Book to purchase :");
int
choice=sc.nextInt();
if(choice>=0
&& choice<=cnt)
{
if(books[choice-1].getNoOfCopies()!=0)
{
shoppingCart[shopCount]=books[choice-1];
books[choice-1].setNoOfCopies(books[choice-1].getNoOfCopies()-1);
tot+=books[choice-1].getPrice();
shopCount++;
System.out.println("**Book
Added to Shopping cart **");
}
}
else
{
System.out.println("Invalid must be between 0 -
"+cnt);
}
System.out.println("Do you want to check out (y/n):");
char
ch=sc.next(".").charAt(0);
if(ch=='y' ||
ch=='Y')
{
break;
}
}
System.out.println("Total Shopping
cart amount :$"+tot);
}
}
_________________________________
// Test.java
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
BookStore b=new BookStore();
b.addBook(new Book("Let us
C","Yashavant Kanetkar","Technology",23.00,10));
b.addBook(new Book("Ansi
C","Balagurusamy","Technology",20.00,10));
b.addBook(new Book("The Elements of
Style","Charles","Fashion",13.00,10));
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
while(true)
{
System.out.println("\n1.List all books");
System.out.println("2.Search Book");
System.out.println("3.Purchase Book");
System.out.println("4.Quit");
System.out.print("Enter Choice :");
int
choice=sc.nextInt();
switch(choice)
{
case 1:{
b.listAllBooks();
continue;
}
case 2:{
b.searchBook();
continue;
}
case 3:{
b.purchaseBooks();
continue;
}
case 4:{
break;
}
default:{
System.out.println("** Invalid Chocie
**");
continue;
}
}
break;
}
}
}
_________________________________
Output:
1.List all books
2.Search Book
3.Purchase Book
4.Quit
Enter Choice :3
1 Let us C Yashavant Kanetkar Technology $23.0
10
2 Ansi C Balagurusamy Technology $20.0 10
3 The Elements of Style Charles Fashion $13.0
10
Enter Index of Book to purchase :3
**Book Added to Shopping cart **
Do you want to check out (y/n):
n
1 Let us C Yashavant Kanetkar Technology $23.0
10
2 Ansi C Balagurusamy Technology $20.0 10
3 The Elements of Style Charles Fashion $13.0
9
Enter Index of Book to purchase :2
**Book Added to Shopping cart **
Do you want to check out (y/n):
n
1 Let us C Yashavant Kanetkar Technology $23.0
10
2 Ansi C Balagurusamy Technology $20.0 9
3 The Elements of Style Charles Fashion $13.0
9
Enter Index of Book to purchase :1
**Book Added to Shopping cart **
Do you want to check out (y/n):
y
Total Shopping cart amount
:$56.0
1.List all books
2.Search Book
3.Purchase Book
4.Quit
Enter Choice :1
Let us C Yashavant Kanetkar Technology $23.0
9
Ansi C Balagurusamy Technology $20.0 9
The Elements of Style Charles Fashion $13.0
9
1.List all books
2.Search Book
3.Purchase Book
4.Quit
Enter Choice :2
1.Keyword in a book title
2.author
3.book category
Enter Chocie:3
Enter book category :fashion
The Elements of Style Charles Fashion $13.0
9
1.List all books
2.Search Book
3.Purchase Book
4.Quit
Enter Choice :4
_______________Could you plz rate me well.Thank
You
Write a program for the management of a bookstore in Java Programming Language, WITHOUT THE USE...
Write a program for the management of a bookstore in java, WITHOUT THE USE OF BOOK CLASS, just arrays, strings, loops, etc. Overview; First menu 1. List all books 2. Search all books 3. Purchase books 4. Exit If option 1 is chosen: List all books by Title, Author, Price, Copies, Category within a group of arrays If option 2 is chosen: Search all books by Title, Author, Price, Copies, Category If option 3 is chosen: List books, List shopping...
design a C program to control the stock of books of a small bookstore. Part 1: for the cout, it should be printf(" "); should write like that When a client orders a book, the system should check if the bookstore has the book in stock. If the bookstore keeps the title and there is enough stock for the order, the system should inform the price per copy to the client, as well as the total price of the purchase....
(JAVA NetBeans) Write programs in java Example 9.13~9.15 //Book.Java public class Book { private String title; private String author; private double price; /** * default constructor */ public Book() { title = ""; author = ""; price = 0.0; } /** * overloaded constructor * * @param newTitle the value to assign to title * @param newAuthor the value to assign to author * @param newPrice the value to assign to price */ public Book(String newTitle, String newAuthor, double newPrice)...
Write a C program to create a list of books details. The details of a book include title, author, publisher, publishing year, no. of pages , price Perform the following with respect to the list of books created Display all the details of books written by a given author. Sort the details of books in the increasing order of price. Display the details of books published by a given publisher in a given year. Sort the list of books in...
It written in can be python or java There is a bookstore that have the title, year, price is should display all the books in the collection when given the list of books some wants to purchase it will return the total amount they need to pay for example with a list of books like: great expectations, 1861, 13.21 wind in the willows, 1999, 5.89 great gatsby ,1914,20.90 it should show a list of the books at the start when...
please use C++ write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. each line in the file has tile, ..... write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. Each line in...
JAVA Objective : • Learning how to write a simple class. • Learning how to use a prewritten class. • Understanding how object oriented design can aid program design by making it easier to incorporate independently designed pieces of code together into a single application. Instructions: • Create a project called Lab13 that contains three Java file called Book.java , Bookstore.java and TempleBookstore.java • I’ve provided a screenshot of how your project should look like. • Be sure to document...
Subject: Java Program You are writing a simple library checkout system to be used by a librarian. You will need the following classes: Patron - A patron has a first and last name, can borrow a book, return a book, and keeps track of the books they currently have checked out (an array or ArrayList of books). The first and last names can be updated and retrieved. However, a patron can only have up to 3 books checked out at...
I need this python program to access an excel file, books inventory file. The file called (bkstr_inv.xlsx), and I need to add another option [search books], option to allow a customer to search the books inventory, please. CODE ''' Shows the menu with options and gets the user selection. ''' def GetOptionFromUser(): print("******************BookStore**************************") print("1. Add Books") print("2. View Books") print("3. Add To Cart") print("4. View Receipt") print("5. Buy Books") print("6. Clear Cart") print("7. Exit") print("*****************************************************") option = int(input("Select your option:...
You need to program a simple book library system. There are three java classes Book.java // book object class Library.java //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...