Guest User

Untitled

a guest
Jul 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.10 KB | None | 0 0
  1. import javax.swing.*;
  2. public class Cad_Vendas1 {
  3.     private static String [] cadastro;
  4.  
  5.     private static String Codigo_produto;
  6.     private static String Nome_Produto;
  7.     private static String Preco_vendas;
  8.     private static String Preco_custo;
  9.  
  10.     private static String menu = "========= SISTEMA DE VENDAS =========\n\n" +
  11.                                  "[1]:....................CADASTRAR PRODUTOS\n"
  12.                                 +"[2]:....................VENDAS\n"
  13.                                 +"[3]:....................COSULTA\n"
  14.                                 +"[4]:....................RELATORIO\n"
  15.                                 +"[5]:....................SAIR\n";
  16.  
  17.  
  18.     public static void main (String [] args){
  19.         String opcao = "";
  20.  
  21.         do {
  22.                 opcao = JOptionPane.showInputDialog(menu);
  23.                
  24.                 if(opcao.equals("1"))
  25.                 {  Cadastrar_Produtos();
  26.                
  27.                 }if(opcao.equals("2")){
  28.                    Realizar_Vendas();
  29.                    
  30.                 }if(opcao.equals("3")){
  31.                     Consultar();
  32.                    
  33.                 }if(opcao.equals("4")){
  34.                     Relatorio();
  35.                    
  36.                 }
  37.        
  38.  
  39.         }
  40.             while(!opcao.equals("5"));
  41.         }
  42.  
  43.  
  44.     private static void Cadastrar_Produtos() {
  45.         // TODO Auto-generated method stub
  46.         int qtd = Integer.parseInt(JOptionPane.showInputDialog("Digite a quntidade de produto que deseja cdastrar"));
  47.         cadastro = new String [qtd];
  48.  
  49.         for(int i = 0; i < qtd; i ++){
  50.         Nome_Produto = JOptionPane.showInputDialog("Digite nome do produto: ");
  51.         Codigo_produto = JOptionPane.showInputDialog("Digite Codigo: ");
  52.         Preco_custo =  (JOptionPane.showInputDialog("Preco de custo"));
  53.         Preco_vendas = (JOptionPane.showInputDialog("Preco de Venda"));
  54.  
  55.  
  56.             }
  57.         JOptionPane.showMessageDialog(null, "Produtos cadastrados com sucesso!");
  58.    
  59.     }
  60.  
  61.     private static void Realizar_Vendas() {
  62.         // TODO Auto-generated method stub
  63.        
  64.     }
  65.  
  66.  
  67.     private static void Consultar() {
  68.         // TODO Auto-generated method stub
  69.        
  70.         String opcao = "";
  71.         String procura = null;
  72.         String Menu_Consulta = "\n\n[A]:.............. Consultar por Código \n"
  73.                     +"[B]:..............Consultar po nome \n"
  74.                     +"[C]:..............SAir do modo Pesquisa";
  75.         opcao = JOptionPane.showInputDialog(Menu_Consulta);
  76.    
  77.         if(opcao.equalsIgnoreCase("A"))
  78.         {
  79.            
  80.             int Codigo_De_Procura = Integer.parseInt(JOptionPane.showInputDialog("Digite O codigo do produto"));   
  81.             for(int i = 0; i < cadastro.length; i ++){
  82.                
  83.                 if(cadastro[i].equals(Codigo_De_Procura)){
  84.                     procura = cadastro[i];
  85.                 }JOptionPane.showMessageDialog(null, "Relatorio de pesquisa \n\n" + procura);
  86.             }
  87.         }
  88.        
  89.     }
  90.  
  91.     private static String toString(String string) {
  92.         // TODO Auto-generated method stub
  93.         return null;
  94.     }
  95.  
  96.     private static void Relatorio() {
  97.         // TODO Auto-generated method stub
  98.         String relatorio = "################## RELATORIO ################# \n\n";
  99.        
  100.         for (int i = 0; i < cadastro.length; i ++){
  101.             relatorio += "NOME do produto: " + Nome_Produto + "\n";
  102.             relatorio += "Codigo: " + Codigo_produto + "\n";
  103.             relatorio += "preço de venda: " +Preco_vendas + "\n";
  104.             relatorio += "preço de Custo: " +Preco_custo + "\n";
  105.             relatorio += " ---------------------------------------------------------------\n";
  106.         }
  107.        
  108.         JOptionPane.showMessageDialog(null," "+ relatorio);
  109.        
  110.     }  
  111.        
  112. }
Add Comment
Please, Sign In to add comment