write java code discount bookstore 1 Answer(s) 3 years and 7 months ago
Posted in : Java Beginners
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 Pages:
write java code discount bookstore - Java Beginners writejavacodediscount 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
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
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
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
Java Application for Book Store JavaBookstore Application
In this Java Tutorial section, we have created a JavaBookstore Application through which a customer can buy books and online pay... at a time.
Here is the code:
import java.util.*;
class Books {
public
help to write java code
help to writejava 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 writejava 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
write spreadsheet write spreadsheet what is the javacode to write a spreadsheet to database
write spreadsheet write spreadsheet what is the javacode to write a spreadsheet to database
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
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
Please write code for this program in java and Explain it ? pl'sssssssss
Please writecode 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
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
Read Write
Read Write Hi;
How can I read certain line of say 10 text files and write to one text file
Java Read Multiple Files and store the data into another text file
The given code reads all the text files of the directory
code
code <
comp xlink:type="new" xlink:actuate="onload"/>
how to write this in java
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 javacode or any software is present
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 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
write code in c# writecode in c# sir
I want to write a save and save as code in the c#(windosForm).Please help me
Java - Java Beginners
Java write a program to simulate a bookstore. The book store has two types of customers: those who are members of the bookstore and those who buy... membership fee and receives a 5% discount on each book bought.
For each member
Java Write to File JavaWrite 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
java code java code write a javacode to convert hindi to english using arrays
How to write image in Jmagick
How to write image in Jmagick hi,
I am new in Java I am using the Jmagick library, how can I write an image in Jmagick ?
Thanks.
hi,
You can try this snippet into your code
ImageInfo ii = new ImageInfo("abc.jpg
Java Showroom Application Java Showroom Application
We have created an application for showroom... to be paid by the customers after the discount on purchase of items. There is a discount on the following items:
T Shirt - 10% discount
Silk sari- 30% discount
Java file read write operation Java file read write operation how to read and write the data from... a sample codecode for writing object
oos = new ObjectOutputStream(fos...");
oos.writeInt(8000);
oos.writeObject("Ankit");
oos.writeObject("Java
How to write a simple java applet
How to write a simple java applet Hi, how can i write a simple java applet, displaying text in specific colors and font style.
For example... in green color
Help me pls :(
Hi Friend,
Try the following code
java code java code write a javacode 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
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 writecode to to append the
content
Java Write To File - Java Tutorial
.
Here is the code of java program to write text to a
file... JavaWrite To File - Java Tutorial
Learn how to write to a file from... on a
FileOutputStream classes to write data to a file from Java program
Java Write To File By Line JavaWrite To File By Line
In this tutorial you will learn how to write to file by line
Write to a file by line using java you can use the newLine()
method... this example :
After doing the basic process to execute a java program write
how to write function of copy from one to another location in this code
how to write function of copy from one to another location in this code I need to write a code to copy a file from one location to another using browse button in it. i have written code for the browse button. please help me
java code java code Write a program to find the difference between sum of the squares and the square of the sums of n numbers
Java Code Java Code Write a java program, which creates multiple threads. Each thread performs add/delete/update operations on an ArrayList simultaneously
Java Write To File CSV JavaWrite To File CSV
In this tutorial you will learn how to write to file... this example :
After doing the basic process to execute a java program write... with containing the text that you are trying to
write in that file by java program like
java code java code An employee _id consist of 5 digits is stored in a string variable strEmpid. Now Mr.Deb wants to store this Id in Integer type to IntEmpid. writeJava statements to do
Java Write To File Binary JavaWrite To File Binary
In this tutorial you will learn how to write... types can
be formed to a byte of 8 bits. Write to a binary file in java... process to execute a java program write simply on
command prompt as :
javac
java code java code Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
Java Write To File - Java Tutorial
of OutputStreamWriter class that is used to write
text (as opposed to binary data... an
internal FileOutputStream to write bytes
to the specified file
BufferedWriter :
The BufferedWriter class is used to write text
Java write file Javawrite file
Following example demonstrates, how to create and
write a file.... java
import java.io.*;
public class Write
java code java code HOW TO PRINT 1 TO 100 WITHOUT USING CONDITIONAL,ANY LOOP AND ARRAY IN JAVA AND C.URGENT SIR PLZ Hi,
You can use following code:
class MyClass
{
public static void main(String[] args)
{
int
Java code Java code Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any... the following code:
import java.util.*;
import java.text.*;
class NumberProgram
Java Write To File BufferedWriter
to
write into the file by java program.
Download Source Code...JavaWrite To File BufferedWriter
In this tutorial you will learn how to write... the basic process to execute a java program write simply on
command prompt
Java Write To File FileOutputStream JavaWrite To File FileOutputStream
In this tutorial you will learn how to write to file using FileOutputStream.
Write to file using FileOutputStream you... with containing the text that you are trying to
write in that file by java
java code java code Write a function Model-of-Category for a Tata motor dealers, which accepts category of car customer is looking for and returns the car Model available in that category. the function should accept the following