Created
November 30, 2012 22:32
-
-
Save 0x000000AC/4179184 to your computer and use it in GitHub Desktop.
This program shows a "purchase order" using JOptionPane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************** | |
* JOptionPurchaseOrder.java | |
* Aaron P. Clark | |
* | |
* This program calculates and prints a purchase order amount | |
***********************************************/ | |
import javax.swing.JOptionPane; | |
public class JOptionPurchaseOrder | |
{ | |
public static void main(String[] args) | |
{ | |
String itemName; // name of purchase item | |
double price; // price of purchase item | |
int qty; // number of items purchased | |
itemName = JOptionPane.showInputDialog("Name of purchase item:"); | |
price = Double.parseDouble( | |
JOptionPane.showInputDialog("Price of one item:")); | |
qty = Integer.parseInt( | |
JOptionPane.showInputDialog("Quantity:")); | |
JOptionPane.showMessageDialog(null, | |
"PURCHASE ORDER:\n\n" + | |
"Item: " + itemName +"\nQuantity: " + qty + | |
"\nTotal price: $" + price * qty); | |
} // end main | |
} // end JOPtionPurchaseOrder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment