This example is 3 rooms with different capacities that record sales of 3 different promotions ($ 1000, $ 1500, $ 2000) what it does is sell and then see the sales report for each location. PD: It is a basic example ...
/ / Class Locales.java
import javax.swing .*; / **
* * @ author Jorge
private int totalventa; local1 Vector = new Vector (this.capacidad_local1)
local2 Vector = new Vector (this.capacidad_local2)
local3 Vector = new Vector (this.capacidad_local3)
/ / Number of Elements
to Store capacidad_local1 public int = 20; public int capacidad_local2 = 25;
capacidad_local3 public int = 33; / / Expenditures For Local
Fihjos gastos_local1 public int = 5000;
gastos_local2 public int = 6000;
gastos_local3 public int = 7000;
Local public
() {
this.totalventa = 0;}
venderPromocion public void () {int
combo1 = 1000;
combo2 int = 1500;
combo3 int = 2500;
this.totalventa = 0;
int local = Integer.parseInt (JOptionPane.showInputDialog ("Select Locations: \\ n" +
"1 - Local 1 \\ n "+
" 2 - Local 2 \\ n "+
" 3 - Local 3 "));
if (local == 1) {
purchase
int = Integer.parseInt (JOptionPane.showInputDialog (" Select Promotion: \\ n "+
" 1 - Combo 1 $ 1000 \\ n "+
" 2 - Combo 2 $ 1500 \\ n "+
" 3 - Combo 3 $ 2500 "));
if (buy == 1)
purchase = combo1;
if (buy == 2)
purchase = combo2;
if (buy == 3)
purchase = combo3;
int qty = Integer.parseInt (JOptionPane.showInputDialog ("Select number of promotions:")) ;
/ / The Limit Purchases can not be greater than capacidad_local1
if (qty> this.capacidad_local1)
{JOptionPane.showMessageDialog (null, "You can buy a maximum" + +
this.capacidad_local1 "Promotions", "ALERT", JOptionPane.INFORMATION_MESSAGE )
Integer.parseInt (JOptionPane.showInputDialog ("Select number of promotions:"));}
this.totalventa = cannot * purchase;
local1.addElement (totalventa)
JOptionPane.showMessageDialog (null, "should Cancel $ "+ totalventa," ALERT "JOptionPane.INFORMATION_MESSAGE);}
if (local == 2) {Int
purchase = Integer.parseInt (JOptionPane.showInputDialog ("Select Promotion: \\ n" +
"1 - Combo 1 $ 1000 \\ n" +
"2 - Combo 2 $ 1500 \\ n" +
"3 - Combo 3 $ 2,500 "));
if (buy == 1) = combo1
purchase;
if (buy == 2) purchase = combo2; if (buy == 3)
purchase = combo3;
int cannot = Integer. parseInt (JOptionPane.showInputDialog ("Select number of promotions:"));
if (qty> this.capacidad_local2)
{JOptionPane.showMessageDialog (null, "You can buy a maximum" + +
this.capacidad_local2 "Promotions", "ALERT" JOptionPane.INFORMATION_MESSAGE)
Integer.parseInt (JOptionPane.showInputDialog ("Select number of promotions:"));}
this.totalventa = qty *
purchase;
local2.addElement ( totalventa)
JOptionPane.showMessageDialog (null, "must pay $" + totalventa, "ALERT" JOptionPane.INFORMATION_MESSAGE)
} if (local == 3) {
purchase
int = Integer.parseInt (JOptionPane . showInputDialog ("Select Promotion: \\ n" +
"1 - Combo 1 $ 1000 \\ n" +
"2 - Combo 2 $ 1500 \\ n" +
"3 - Combo 3 $ 2500 "));
if (buy == 1) = combo1
purchase;
if (buy == 2)
purchase = combo2;
if (buy == 3)
purchase = combo3;
int cannot = Integer.parseInt (JOptionPane.showInputDialog ("Select number of promotions:"));
if (qty> this.capacidad_local3)
{JOptionPane.showMessageDialog (null, "You can buy a maximum" + +
this.capacidad_local3 "Promotions" "ALERT" JOptionPane.INFORMATION_MESSAGE)
Integer.parseInt (JOptionPane.showInputDialog ("Select number of promotions:"));}
this.totalventa = cannot * purchase;
local3.addElement (totalventa)
JOptionPane.showMessageDialog (null, "must pay $" + totalventa, "ALERT" JOptionPane.INFORMATION_MESSAGE)
}}
verVentasTotales public void () {
/ / Report
Local 1
String Output = "Index \\ tValor \\ n";
for (int i = 0; i
output + = i + "\\ t" + local1.elementAt (i) + "\\ t" + "\\ n";}
ventanaSalida = new JTextArea JTextArea ();
ventanaSalida.setText (Output);
JOptionPane.showMessageDialog (null, ventanaSalida, "LOCAL REPORT 1" JOptionPane.INFORMATION_MESSAGE)
/ / Report
Local 2
OUTPUT2 String = "Index \\ tValor \\ n";
for (int i = 0; i
OUTPUT2 + = i + "\\ t" + local2.elementAt (i) + "\\ n";}
ventanaSalida2 = new JTextArea JTextArea ();
ventanaSalida2.setText (OUTPUT2)
JOptionPane.showMessageDialog ( null, ventanaSalida2, "REPORT LOCAL 2" JOptionPane.INFORMATION_MESSAGE)
/ / Report Local 3
OUTPUT3 String = "Index \\ tValor \\ n";
for (int i = 0; i
OUTPUT3 + = i + "\\ t" + local3.elementAt (i) + "\\ n";}
ventanaSalida3 = new JTextArea JTextArea ();
ventanaSalida3.setText ( OUTPUT3)
JOptionPane.showMessageDialog (null, ventanaSalida3, "LOCAL REPORT 3" JOptionPane.INFORMATION_MESSAGE)
}}
/ / Class Main.java
import javax.swing .*;
/ **
* * @ author Jorge
* / Public class * /
public static void main (String [] args) {
/ / TODO code application logic here Local milocal = new Local ();
do
"1 - Sales \\ n" +
"2 - Sales Report \\ n" +
"3 - Exit"));
switch (x) {
/ / Sales
case 1: milocal.venderPromocion ();
/ / ask for another operation such as calculating sales or continue selling
int b = Integer.parseInt (JOptionPane.showInputDialog ("Press: \\ n "+
" 1 - continue \\ n "+
" 2 - Quit \\ n "));
if (b == 2)
continue = false;
break;
/ / Reports, reports show of the 3 rooms together
case 2: milocal.verVentasTotales ();
/ / ask for another operation such as calculating sales or continue selling
b = Integer.parseInt (JOptionPane.showInputDialog ("Press: \\ n" + "1 - continue \\ n" +
"2 - Quit \\ n"));
if (b == 2) continue =
false; break;
/ / exit system
case 3: continue = false;;
default: break;
}} while (continue); / / will be output from
JOptionPane.showMessageDialog (null, "Have a nice day", "Close System", JOptionPane.INFORMATION_MESSAGE) }}
Let's see some screenshots
Local Menu
Menu Promotions
Number of Promotions to Buy
Total to Pay for Purchase
0 comments:
Post a Comment