Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners write java code discount bookstore

Have Programming Question? Ask it here!
 
 
 


chean
write java code discount bookstore
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners



Advertisement
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
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
Advertisements
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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... In the above program you have learned how to write code to to append the content
write a java program
write a java program  write a program to print '*' in a circular form
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
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
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
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
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 program - Java Beginners
write program  write a java program that will read the values of matrix A and B give its multiplication in matrix C  Hi friend, Code...]); } System.out.println(); } } } For more information on java visit to : http
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 file in Java?
How to Write to file in Java?  How to Write to file in Java Program?   Hi, For writing a file in Java, we need some classes from Java.IO... the Examples of How to write to File in Java Program: WriteToFileExample.java import
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
Write a program in java...
Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two... to enter an integer number. Write a program in java to find the factorial
write a program - Java Beginners
write a program  1. write a program that reads a string composed of 6 words then generate and print a word composed of the first letters of the 6 words.  Hi friend, Code to solve the problem : class FirstLetter
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  How do I write a program in Java, have the program display a message with your name in it and a number (Hello john Smith!1) The number must increment from zero to nine, or decrement fron nine to zero. You
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order
write a program in java.
write a program in java.  arrange the natural n umber in 5x5 matrix as 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 i at centerd position and remaining arrange in anticlockwise direction.  
Java Stream Write Exception
Java Stream Write Exception  I am doing socket programming. I have two files called Server.java and client.java. Both programs were running successfully and successfully sending data to each other. Yesterday I added the following
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
java code
java code  write a java code to convert hindi to english using arrays
Write short note on Java package.
Write short note on Java package.  Write short note on Java package
java code
java code  write a java code for finding a string in partiular position in a delimited text file and replace the word with the values given by user and write the file in new location
Java Write to File
Java Write to File In this tutorial you will learn how to write to file in java. Write to a file in java we are required to use some classes of java.io... doing the basic process to execute a java program write simply on command
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
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file bufferedwriter in Java   In Java there are 2 types of class files used... to write texts. In this classwe stores the character in a buffer to write
how to write java data - XML
how to write java data  how to write data to xml file  Hi friend, Read for more information, http://www.roseindia.net/xml/dom/ Thanks
 

 

 

DMCA.com