write java code discount bookstore

write java code discount bookstore

View Answers

November 12, 2009 at 2:35 PM

Hi Friend,

Try the following code:
import java.util.*;
class Books{
public String title;
public String author;
public int isbn;
public double price;
public double discount;
public double total;

public Books(){}
public Books(String title,String author, int isbn,double price,double discount,double total) {
super();
this.title=title;
this.author= author;
this.isbn = isbn;
this.price=price;
this.discount=discount;
this.total=total;
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public int getIsbn() {
return isbn;
}
public double getPrice() {
return price;
}
public double getDiscount() {
return discount;
}
public double getTotal() {
return total;
}
}
public class BookStore {
public static void main(String[] args) throws Exception {
double amount=0.0;
double sum=0.0;
int count=1;
List<Books> list = new ArrayList<Books>();
Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("Book Store");
System.out.println();
System.out.println("1. Buy book");
System.out.println("2. Receipt");
System.out.println("3. Receive Payment");
System.out.println("4. Exit");
boolean quit = false;
do{
if(count>5){
System.out.println("You cannot buy more than 5 books at a time.");
}
System.out.print("Please enter your choice: ");
menu = scan.nextInt();
System.out.println();
switch(menu) {
case 1:
count++;
System.out.println("Book Title: ");
String booktitle = scan.next();
System.out.println("Author: ");
String auth = scan.next();
System.out.println("ISBN: ");
int no = scan.nextInt();
System.out.println("Price: ");
double p = scan.nextDouble();
System.out.println("Discount: ");
double dis = scan.nextDouble();
double total=p-(dis*p);
list.add(new Books(booktitle,auth,no,p,dis,total));
break;
case 2:
System.out.println("Title Author ISBN Price Discount Total");
for (Books s : list){
System.out.println(s.getTitle()+" " +s.getAuthor()+" " +s.getIsbn()+" "+s.getPrice()+" " +s.getDiscount()+" " +s.getTotal());
sum+=s.getTotal();
}
System.out.println("Total= "+sum);
break;
case 3:
System.out.println("Customer Pays: ");
amount = scan.nextDouble();
double balance=amount-sum;
System.out.println("Balance is: "+balance);
quit = true;
case 4:
quit = true;

break;
default:
System.out.println("Invalid Entry!");
}
}
while (!quit);
}
}

Thanks









Related Tutorials/Questions & Answers:
write java code discount bookstore - Java Beginners
write java code discount bookstore  The question Cik Mat operates bookstore. During their promotion period, there are books which are sold with special discounts, while others are sold at normal price. Write a program which
help to write java code
help to write java code  write a full code to produce a system will calculate all items to get total carry-marks which are 60 marks. and get sum of assignment 1,assignment 2, midterms-test and lave work to get total marks
Advertisements
help to write java code
help to write java code  write a full code to produce a system will calculate all items to get total carry-marks which are 60 marks. and get sum of assignment 1,assignment 2, midterms-test and lave work to get total marks
ModuleNotFoundError: No module named 'odoo10-addon-account-cash-discount-write-off'
ModuleNotFoundError: No module named 'odoo10-addon-account-cash-discount-write...: ModuleNotFoundError: No module named 'odoo10-addon-account-cash-discount-write-off...-account-cash-discount-write-off' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo10-addon-account-cash-discount-write-off'
ModuleNotFoundError: No module named 'odoo10-addon-account-cash-discount-write...: ModuleNotFoundError: No module named 'odoo10-addon-account-cash-discount-write-off...-account-cash-discount-write-off' error? Thanks   Hi, In your
How to write a session code - Java Beginners
How to write a session code   Once Again Thanks Deepak...Thanks for continuing responce I want using session in my project plz help me how to write a session code plz write a session code and post answer my personal id
How to write a error.jsp code - Java Beginners
How to write a error.jsp code  Thanks once again I have a session code pls help me that how can i write a error.jsp page. why use error.jsp...let me know that hw can i write the error.jsp code. plz send me error.jsp code
Please write code for this program in java and Explain it ? pl'sssssssss
Please write code for this program in java and Explain it ? pl'sssssssss ... that were ever alive at one time. Write a method to compute this, given the above array of 2n integers. Write one of the following methods: C/C++: int
write simple java code - Java Beginners
write simple java code  Write a program that creates a simple calculator .The user enters two numbers in the text fields, Number 1 and Number 2... the following code: import java.awt.*; import javax.swing.*; import
write code in c#
write code in c#  sir I want to write a save and save as code in the c#(windosForm).Please help me
the discount system.
the discount system.  hi.. im a beginner here in java. sadly i was asked to code this one. about inheritance. and i absolutely dont know how.. will someone will help me with this? please. i was asked to write a discount system
the discount system.
the discount system.  hi.. im a beginner here in java. sadly i was asked to code this one. about inheritance. and i absolutely dont know how.. will someone will help me with this? please. i was asked to write a discount system
how to write code for this output?
how to write code for this output?   1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Write JQUERY Code
Write JQUERY Code  Hi, Iam swathi.I created the table in the below format.can u please write the jquery code of this table..and my requirement... please send me the code through jquery..? Thank you Swathi
Write JQUERY Code
Write JQUERY Code  Hi, Iam swathi.I created the table in the below format.can u please write the jquery code of this table..and my requirement... please send me the code through jquery..? Thank you Swathi
ModuleNotFoundError: No module named 'bookstore'
ModuleNotFoundError: No module named 'bookstore'  Hi, My Python... 'bookstore' How to remove the ModuleNotFoundError: No module named 'bookstore' error? Thanks   Hi, In your python environment you
Can i write JavaScript code in AjaxResponse Code ?
Can i write JavaScript code in AjaxResponse Code ?  Hai Every Dynamic's We can't write JavaScript code in Ajax Response Code.Why because it takes only html,json,xml response.I tried a lot to create js form in ajax response.It
discount system.
discount system.   i was asked to write a discount system... receive a discount of 20%, 15%, and 10% respectively, for all services provided. Customers without membership receive no discount. all members receives a flat 10
How to write jsp/servlet code to integrate LINKDIN?
How to write jsp/servlet code to integrate LINKDIN?  How integrate linkdin api's in java codding
How to write the code for date in swings - Struts
How to write the code for date in swings  Hi Friends, I want to code for display the calendar.......technologies use only swing and core java also how to display calendar like that popup window.....please write and send me
ModuleNotFoundError: No module named 'write-about-code'
ModuleNotFoundError: No module named 'write-about-code'  Hi, My... named 'write-about-code' How to remove the ModuleNotFoundError: No module named 'write-about-code' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'write-about-code'
ModuleNotFoundError: No module named 'write-about-code'  Hi, My... named 'write-about-code' How to remove the ModuleNotFoundError: No module named 'write-about-code' error? Thanks   Hi, In your
Java Application for Book Store
Java Bookstore Application In this Java Tutorial section, we have created a Java Bookstore Application through which a customer can buy books and online pay... at a time. Here is the code: import java.util.*; class Books { public
JAVA Write code which converts propositional expressions into clauses using the INOA rules
JAVA Write code which converts propositional expressions into clauses using the INOA rules  Write code which converts propositional expressions... are: or not p q or not p r Turn in: ΓΆβ?¬ΒΆ Printout of your code. ΓΆβ?¬ΒΆ Test
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
how to write a programm in C for included code below
how to write a programm in C for included code below  Here is my question 'how to write a program in C that runs your sql-xml application session. In the session, you can run SQL queries interactively. The query results
How to Write to a File in Java without overwriting
Learn how to Write to a File in Java without overwriting in your Java program This tutorial teaches you how to write to a file in Java without overwriting..._TO_REPLACE_6 In the above program you have learned how to write code to to append
software or i have to write a code for this suff
convert windows picture or fax viewer file into ms word or pdf   sir i want to convert windows picture or fax viewer file into ms word or pdf so for this is i have to take help from the java code or any software is present
How to write the junit test code for the following controller code
How to write the junit test code for the following controller code  //Controller Code package com.payoda.springs; import java.util.ArrayList... "Volumereturn"; } } // Mock test code package com.payoda.test
write a java program
write a java program  write a program to print '*' in a circular form
Java write to file
Java write to file  How to write to a file in Java? Is there any good example code here? Thanks   Hi, Java is one of the best... files. You can easily use the the FileWriter and BufferedWriter to write data
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
how to write weighted moving average code using 2d-array
how to write weighted moving average code using 2d-array  how to write weighted moving average code using 2d-array
online bookstore - JSP-Servlet
online bookstore  i want to display some books like online shoping.please send me code for that using jsp and servlets
online bookstore - JSP-Servlet
online bookstore  i want code for online bookshop.please send mo soon..........  Hi Friend, Please specify some details. Thanks
ModuleNotFoundError: No module named 'UW-RestClients-bookstore'
ModuleNotFoundError: No module named 'UW-RestClients-bookstore'  Hi...: No module named 'UW-RestClients-bookstore' How to remove the ModuleNotFoundError: No module named 'UW-RestClients-bookstore' error? Thanks  
write a programm using java
write a programm using java  print the following using java programming
write java prgram
write java prgram  write java program to offer a menu which contains 3 choices to make calculation on 3 shapes.use method for each calculation
if my database(oracle) connection failure means wat is the code to write in exception ?
if my database(oracle) connection failure means wat is the code to write in exception ?  if my database(oracle) connection failure means wat is the code to write in exception
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
write the java program?
write the java program?  1 11 121 1331 14641 15101051
write the java program?
write the java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... to write in File of Java Program... the (BufferedReader) constructor. So that we write some data suing
Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
How to write Example code for CRUD application in hibernate annotation?
How to write Example code for CRUD application in hibernate annotation?  Learn Hibernate can be easy if anyone help me with the simple example code. How to write Example code for CRUD application in hibernate annotation? Share

Ads