Question

It written in can be python or java There is a bookstore that have the title,...

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 user inputs the the book they will get the total price back, the user should also be able to buy more than one book

10% discount if the price is above £20

20% discount if the year of the book is from 1999

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

books_names=['great expectations','wind in the willows','great gatsby','the monk who sold his ferrari'
,'who will cry when you die','Wings of Fire'] #List of books names
books_years=[1861,1999,1914,1998,1898,1999] #list off books years
books_prices=[13.21,5.89,20.90,100.23,89,99.98] #corresponding prices
def printMenu (): #menu which prints the details of books
print()
for i in range (0,len(books_names)):
print(books_names[i]+"," +str(books_years[i]) + "," + str(books_prices[i])) #print details of books
printMenu() #printing menu by starting of program
Total_Cost=0.0
input_book=input("\nEnter the book name you want to buy: ") #asking user to enter the book name
while input_book!='No': #if input is No quit the program
book_price=0.0
flag=0 #used to check whether book is invalid
for i in range (0,len(books_names)): #if not check whether the book is present in the books list
if input_book==books_names[i]:
if books_years[i]==1999 and books_prices[i]>20:
book_price=books_prices[i]-(books_prices[i]*0.3) #directly 20% + 10 % =30% book is from 1999 and price>20
elif books_years[i]==1999: #if book is only from 1999 give 20% discount
book_price=books_prices[i]-(books_prices[i]*0.2)
elif books_prices[i]>20:
book_price=books_prices[i]-(books_prices[i]*0.1) #if book prices is greater than 20 give 10%
break
flag+=1 #increment flag variable
if (flag==len(books_names)):
print("\nWrong Book Entered Please Enter Proper Book name\n") #if flag equals length that means book not founded
else:
Total_Cost=Total_Cost+book_price #else add book price to total cost
printMenu() #print menu
print("\nDo you want to buy some more books if yes please enter book name else please type No:")
input_book=input("Enter your choice (If No type quit): ") #take input from user again
if (input_book=='quit'): #if user enters quit terminate loop
break
print("Total price is" , Total_Cost) #finally print total cost


Code Screenshots and Output:

Note: if you have any queries please post a comment thanks a lot.. always available to help you....

Add a comment
Know the answer?
Add Answer to:
It written in can be python or java There is a bookstore that have the title,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (JAVA NetBeans) Write programs in java Example 9.13~9.15 //Book.Java public class Book { private String title; private...

    (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 program for the management of a bookstore in java, WITHOUT THE USE OF BOOK...

    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...

  • 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 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,...

  • Problem 4 (DOM operations - 30 points): Consider the Python code snippet bookstore.py for DOM operation,...

    Problem 4 (DOM operations - 30 points): Consider the Python code snippet bookstore.py for DOM operation, some basic methods and properties and an xml file on bookstore which we discussed this week. Wite two func- tions; First, write a recursive Python function get_text(elm) to extract all the text of a dom tree pointed by elm. For example, get_text(elm), where elm=<bookstore>, will return [[u'Emacs User Manual', u'Richard Stallman', u'1980', u'12.00'], [u'Timeline', u'Michael Chricton', u'1999', u'15.00'], [u'Catch 22', u'Joseph Heller', u'1961', u'20.00'],...

  • JAVA Objective : • Learning how to write a simple class. • Learning how to use...

    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...

  • Database Management ID Title 1 Author Richie Karen с JAVA Script Java Year 1955 1958 1959...

    Database Management ID Title 1 Author Richie Karen с JAVA Script Java Year 1955 1958 1959 Price 10 20 10 2 4 5 6 C++ prolog Peri Schwartz Ross Maria 1959 1972 20 10 7 Wall 1987 20 The above relation has formation about different books. The table information is already saved as txt format in Moodle under the name Quiz2Data.txt. Using MySql on your computer do: Create a database • Create a table with name book, then load Quiz2Data.txt...

  • design a C program to control the stock of books of a small bookstore. Part 1:...

    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....

  • help create a table data.txt 1,C,Richie,1955 2,JAVA Script,Karen,1958 4,Java,Schwartz,1959 5,C++,Ross,1959 6,prolog,Maria,1972 7,Perl,Wall,1987 ID Title Year Price...

    help create a table data.txt 1,C,Richie,1955 2,JAVA Script,Karen,1958 4,Java,Schwartz,1959 5,C++,Ross,1959 6,prolog,Maria,1972 7,Perl,Wall,1987 ID Title Year Price 1 Author Richie Karen 1955 1958 10 20 2 4 C JAVA Script Java C++ prolog 1959 10 5 Schwartz Ross Maria 1959 1972 20 10 6 7 Perl Wall 1987 20 The above relation has information about different books. The table information is already saved as txt format in Moodle under the name Quiz2Data.txt. Using MySql on your computer do: Create a database...

  • Python: I need help with the following quit function ! The quit menu option should not...

    Python: I need help with the following quit function ! The quit menu option should not be case sensitive - 'q' or 'Q' should quit the program menu.add_option('Q', 'Quit', quit_program) NB: Remaining code ! """ Program to create and manage a list of books that the user wishes to read, and books that the user has read. """ from bookstore import Book, BookStore from menu import Menu import ui store = BookStore() def main(): menu = create_menu() while True: choice...

  • I need this python program to access an excel file, books inventory file. The file called...

    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:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT