public class Menu extends JFrame implements ActionListener{
public JButton btnPozole, btnSopa, btnMole, btnPancita, btnPollo, btnFiletes,btnChicharron, btnPechugas;
public JButton btnQuesadillas, btnSopes, btnGorditas,btnEspagueti,btnBizteces,btnEnsalada,btnBarbacoa,btnArroz;
public JLabel lblTotal, lblEfectivo;
public JTextField txtEfe;
public JButton btnCobrar, btnBorrar, btnSalir;
public int pozole, sopa, mole, pancita, pollo, filetes,chicharron,pechugas,quesadillas,sopes,gorditas,espagueti,bizteces,ensalada,barbacoa,arroz, total;
public static void main(String args[]){
Menu ventana = new Menu();
ventana.setDefaultCloseOperation(EXIT_ON_CLOSE);
ventana.setSize(400,400);
ventana.setTitle("MENU JESSIKITA");
ventana.setVisible(true);
ventana.crearGUI();
ventana.setLocationRelativeTo(null);
}
public void crearGUI(){
Container panel = getContentPane();
panel.setLayout(new FlowLayout());
btnPozole = new JButton("Pozole");
btnPozole.addActionListener(this);
panel.add(btnPozole);
btnQuesadillas = new JButton("Quesadillas");
btnQuesadillas.addActionListener(this);
panel.add(btnQuesadillas);
btnMole = new JButton("Mole");
btnMole.addActionListener(this);
panel.add(btnMole);
btnPancita = new JButton("Pancita");
btnPancita.addActionListener(this);
panel.add(btnPancita);
btnPollo = new JButton("Pollo");
btnPollo.addActionListener(this);
panel.add(btnPollo);
btnFiletes = new JButton("Filetes");
btnFiletes.addActionListener(this);
panel.add(btnFiletes);
btnChicharron = new JButton("Chicharron");
btnChicharron.addActionListener(this);
panel.add(btnChicharron);
btnPechugas = new JButton("Pechugas");
btnPechugas.addActionListener(this);
panel.add(btnPechugas);
btnSopa = new JButton("Sopa");
btnSopa.addActionListener(this);
panel.add(btnSopa);
btnSopes = new JButton("Sopes");
btnSopes.addActionListener(this);
panel.add(btnSopes);
btnGorditas = new JButton("Gorditas");
btnGorditas.addActionListener(this);
panel.add(btnGorditas);
btnEspagueti = new JButton("Espagueti");
btnEspagueti.addActionListener(this);
panel.add(btnEspagueti);
btnBizteces = new JButton("Bizteces");
btnBizteces.addActionListener(this);
panel.add(btnBizteces);
btnEnsalada = new JButton("Ensalada");
btnEnsalada.addActionListener(this);
panel.add(btnEnsalada);
btnBarbacoa = new JButton("Barbacoa");
btnBarbacoa.addActionListener(this);
panel.add(btnBarbacoa);
btnArroz = new JButton("arroz");
btnArroz.addActionListener(this);
panel.add(btnArroz);
lblTotal = new JLabel("Total $0.0");
lblTotal.setForeground(Color.red);
panel.add(lblTotal);
lblEfectivo = new JLabel("Efectivo ");
panel.add(lblEfectivo);
txtEfe = new JTextField(10);
panel.add(txtEfe);
btnCobrar = new JButton("Cobrar");
btnCobrar.addActionListener(this);
panel.add(btnCobrar);
btnBorrar = new JButton("Borrar");
btnBorrar.addActionListener(this);
panel.add(btnBorrar);
btnSalir = new JButton("Salir");
btnSalir.addActionListener(this);
panel.add(btnSalir);
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
if (arg0.getSource() == btnPozole) {
pozole++;
total+=35;
}
if (arg0.getSource() == btnSopa) {
sopa++;
total+=15;
}
if (arg0.getSource() == btnMole) {
mole++;
total+=20;
}
if (arg0.getSource() == btnPancita) {
pancita++;
total+=40;
}
if (arg0.getSource() == btnPollo) {
pollo++;
total+=25;
}
if (arg0.getSource() == btnFiletes) {
filetes++;
total+=25;
}
if (arg0.getSource() == btnChicharron) {
chicharron++;
total+=20;
}
if (arg0.getSource() == btnPechugas) {
pechugas++;
total+=30;
}
if (arg0.getSource() == btnQuesadillas) {
quesadillas++;
total+=15;
}
if (arg0.getSource() == btnSopes) {
sopes++;
total+=35;
}
if (arg0.getSource() == btnGorditas) {
gorditas++;
total+=15;
}
if (arg0.getSource() == btnEspagueti) {
espagueti++;
total+=25;
}
if (arg0.getSource() == btnBizteces) {
bizteces++;
total+=30;
}
if (arg0.getSource() == btnEnsalada) {
ensalada++;
total+=25;
}
if (arg0.getSource() == btnBarbacoa) {
barbacoa++;
total+=35;
}
if (arg0.getSource() == btnArroz) {
arroz++;
total+=20;
}
if (arg0.getSource() == btnCobrar) {
int efectivo = Integer.parseInt(txtEfe.getText());
if (total>efectivo) {
JOptionPane.showMessageDialog(null, "Falta efectivo");
} else {
int cambio = efectivo-total;
JOptionPane.showMessageDialog(null, "Su cambio = $" + cambio);
}
}
if (arg0.getSource() == btnBorrar) {
total=pozole=sopa=mole=pancita=pollo=filetes=chicharron=pechugas=quesadillas=sopes=gorditas=espagueti=bizteces=ensalada=barbacoa=arroz=0;
lblTotal.setText("Total $0.0");
}
if (arg0.getSource() == btnSalir) {
System.exit(0);
}
lblTotal.setText("Total $" + total);
}
}
lunes, 24 de noviembre de 2014
lunes, 3 de noviembre de 2014
clase Ecuacion
public class Ecuacion {
int a, b,c;
double x1, x2;
public Ecuacion(){}
public Ecuacion(int x, int y, int z){
a=x; b=y; c=z;
}
public double determinante(){
return(b*b-4*a*c);
}
public void solucion(){
if (determinante() ==0){
x1 = -b/2*a;
x2 = -b/2*a;
}
if (determinante()>0){
x1= -b/2*a +(Math.sqrt(determinante())/2*a);
x2= -b/2*a +(Math.sqrt(determinante())/2*a);
}
if (determinante()<0){
}
}
public static void main(String args[]){
Ecuacion uno = new Ecuacion(9,6,10);
uno.determinante();
System.out.println("Det*" + uno.determinante());
uno.solucion();
System.out.println("x1*" + uno.x1);
System.out.println("x2*" + uno.x2);
}
}
int a, b,c;
double x1, x2;
public Ecuacion(){}
public Ecuacion(int x, int y, int z){
a=x; b=y; c=z;
}
public double determinante(){
return(b*b-4*a*c);
}
public void solucion(){
if (determinante() ==0){
x1 = -b/2*a;
x2 = -b/2*a;
}
if (determinante()>0){
x1= -b/2*a +(Math.sqrt(determinante())/2*a);
x2= -b/2*a +(Math.sqrt(determinante())/2*a);
}
if (determinante()<0){
}
}
public static void main(String args[]){
Ecuacion uno = new Ecuacion(9,6,10);
uno.determinante();
System.out.println("Det*" + uno.determinante());
uno.solucion();
System.out.println("x1*" + uno.x1);
System.out.println("x2*" + uno.x2);
}
}
Suscribirse a:
Entradas (Atom)