|

April 23rd, 2012, 03:51 AM
|
|
Authorized User
|
|
Join Date: Mar 2012
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by paulymonz
can anyone give me some examples of programs using JOption which are somehow similar to cashier register or programs used for registration of students or others. They should have the function to add, subtract, delete, update, and can be stored. I need it as an example for our module in our project proposal and project defense.. hope u can help me out..
tnx.. =>
|
Hello colleague,
Please find herewith a similartype ofyour requirements using JOption class etc that requires a little bit of modifications however to enable for the studentregistering task .(replacing InvoiceDetails with StudentDetails)
Thanks if ok
As
muthukutta1
Quote:
import javax.swing.JOptionPane;
import java.util.Formatter;
public class InvoiceWithProductApp
{
public static void main(String[] args)
{
// declare and initialize variables
String choice = "", numberStr = "", productIDStr = "",
typeStr = "", orderQuantityStr = "",outputMessage = "";
int type = 0, orderQuantity = 0;
// declare invoice object
InvoiceWithProduct anInvoice = null;
while (!(choice.equalsIgnoreCase("x")))
{
// get user input
numberStr = JOptionPane.showInputDialog("Enter invoice number: ");
productIDStr = JOptionPane.showInputDialog("Enter product ID: ");
orderQuantityStr = JOptionPane.showInputDialog("Enter order quantity: ");
orderQuantity = Integer.parseInt(orderQuantityStr);
typeStr = JOptionPane.showInputDialog(
"Enter invoice type (1=regular 2=discounted): ");
type = Integer.parseInt(typeStr);
// create Invoice object
anInvoice = new InvoiceWithProduct(numberStr, productIDStr,
orderQuantity, type);
// prepare for output
outputMessage = String.format
( "Invoice number: %s\nInvoice date: %tD\nProduct ID: %s\n"
+ "Product Desc: %s\nProduct price: $%.2f\nOrder quantity: %d\n"
+ "Invoice type: %d\nInvoice discount: %.2f%%\nTax rate: %.2f%%\n"
+ "Invoice total: $%.2f\nInvoice count: %d\n\n"
+ "Press Enter to continue or 'x' to exit:",
anInvoice.getInvoiceNumber(), anInvoice.getInvoiceDate(),
anInvoice.getAProduct().getProductID(),
anInvoice.getAProduct().getProductDescription(),
anInvoice.getAProduct().getProductPrice(),
anInvoice.getOrderQuantity(), anInvoice.getInvoiceType(),
anInvoice.getDiscountPercent() * 100, anInvoice.getTAX_RATE() * 100,
anInvoice.getInvoiceTotal(), InvoiceWithProduct.getInvoiceCount());
// display output
choice = JOptionPane.showInputDialog
(null, outputMessage, "Invoice Application", JOptionPane.PLAIN_MESSAGE);
} // end while
System.exit(0);
} // end main
} // end
|
|