Ir ao conteúdo
  • Cadastre-se

Walquiria Avelar Mourão

Membro Júnior
  • Posts

    6
  • Cadastrado em

  • Última visita

Reputação

0
  1. Podem me ajudar com o exercicio em anexo eu ja fiz algumas partes, só que estou com muitas duvidas. Arquivo html (CadastroFunc) <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>TODO supply a title</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form action='Funcionario.java' method='get'> Nome: <input type= text name='Nome'><br> Sobrenome: <input type=text name='Sobrenome'><br> Salario: <input type="text" name="Salario"><br> Gratificacao: <input type="text" name="Gratificacao"><br> <input type=submit value='Cadastrar'> </form> </body> </html> cabeçalho (JSP) <%-- Document : cabeçalho Created on : 04/11/2016, 20:35:01 Author : aluno --%> <%@page import="java.util.*, java.text.*" %> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Sao Jose</title> </head> <body> <h1> <%! public String fncMES(int mes) { String retorno =""; switch(mes){ case 1: retorno="Janeiro";break; case 2: retorno="Fevereiro";break; case 3: retorno="Março";break; case 4: retorno="Abril";break; case 5: retorno="Maio";break; case 6: retorno="Junho";break; case 7: retorno="Julho";break; case 8: retorno="Agosto";break; case 9: retorno="Setembro";break; case 10: retorno="Outubro";break; case 11: retorno="Novembro";break; case 12: retorno="Dezembro";break; } return retorno; } %> <% int mes = Integer.parseInt(new SimpleDateFormat("M").format(new Date())); int dia = Integer.parseInt(new SimpleDateFormat("dd").format(new Date())); int ano = Integer.parseInt(new SimpleDateFormat("yyyy").format(new Date())); out.println("Faculdades São Jose, " + dia + " de " + fncMES(mes) + " de " + ano); %> </body> </html> index.JSP <%-- Document : index Created on : 04/11/2016, 19:30:33 Author : aluno --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1> <%@page import="java.util.*, java.text.*" %> <% out.println("<h1>Bem-Vindo,</h1>"); int dia = Integer.parseInt((new SimpleDateFormat("dd")).format(new Date())); int mes = Integer.parseInt((new SimpleDateFormat("M")).format(new Date())); int ano = Integer.parseInt((new SimpleDateFormat("yyyy")).format(new Date())); out.println("Data, " + dia + " de " + mes + " de " + ano); %> </h1> <form action='Logar' method='get'> Usuário: <input type="text" name='Usuario'><br> Senha: <input type="text" name='Senha'><br> <input type=submit value='Login'> </form> <h3>Copyrigth Eu</h3> </body> </html> Rodape.JSP <%-- Document : rodape Created on : 04/11/2016, 20:35:19 Author : aluno --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Copyrigth</title> </head> <body> <h1>Hello World!</h1> </body> </html> Pacotes Funcionario.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author aluno */ public class Funcionario { private String nome; private String sobrenome; private Double salario; private Double gratificacao; public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } public String getSobrenome() { return sobrenome; } public void setSobrenome(String sobrenome) { this.sobrenome = sobrenome; } public Double getSalario() { return salario; } public void setSalario(Double salario) { this.salario = salario; } public Double getGratificacao() { return gratificacao; } public void setGratificacao(Double gratificacao) { this.gratificacao = gratificacao; } } Logar.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author aluno */ /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods. * * @param request servlet request * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @WebServlet(urlPatterns = {"/Logar"}) public class Logar extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ Login login = new Login(); String Usuario = request.getParameter("Usuario"); String Senha = request.getParameter("Senha"); login.setUsuario(Usuario); login.setSenha(Senha); out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet Logar</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Data</h1>"); out.println("<h1>bem-vindo, " + login.getUsuario()+ "</h1>"); out.println("<h4>Escolha uma Opcao</h4>"); out.println("</body>"); out.println("</html>"); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> } Login.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author walqu */ public class Login { private String login; private String Senha; public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } public String getSenha() { return Senha; } public void setSenha(String Senha) { this.Senha = Senha; } String getUsuario() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } void setUsuario(String Usuario) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } } POO2_ExercicioServletJSP.pdf adicionado 0 minutos depois Estou utilizando o netbeans
  2. No código deve conter as especificações abaixo: 1) a fila de existir; Sobre a rotina ADICIONAR A rotina deve adicionar (inserir) um único elemento no final da fila (sem looping) Não pode adicionar além do limite (exibir mensagem: número máximo de dados atingido) A rotina deve exibir o elemento adicionado e a sua posição Sobre a rotina EXCLUIR Deve exibir o dado excluído Caso a fila esteja vazia, exibir "FILA VAZIA" Sobre a rotina EXIBIRPRIMEIRO Deve exibir no seguinte formato: (O número xx e o primeiro da fila) Caso a fila esteja vazia, deve exibir: (Nenhum número inserido) Sobre a rotina LISTAGEM (EXIBIR FILA) Caso a fila esteja vazia exibir mensagem (Nenhum elemento inserido) Chamar uma rotina (imprimir) para exibir todos os elementos da fila, incluindo a posição de cada elemento Sobre a rotina ESVAZIAR Exibir mensagem se a fila estiver vazia (Nenhum número inserido) Remover cada elemento enquanto existir dados. Exibir uma mensagem (FILA ESVAZIADA) Esse foi o código digitado no DEV C++, mas gostaria de ajuda para terminá-lo e deixá-lo de acordo com o solicitado acima; #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void ADICIONAR(); void EXCLUIR(); void EXIBIRPRIMEIROELEMENTO(); void EXIBIRFILA(); void ESVAZIAR(); #define MAX 20 /*tamanho maximo da fila*/ typedef int telem; /*Tipo base dos elementos da fila*/ typedef struct { telem v[MAX]; int inicio; /* Posição do primeiro elemento*/ int final; /* Posição do último elemento*/ } tfila; int menu(); void criar (tfila *F); int vazia (tfila F); int primeiro (tfila F, telem *dado); int inserir (tfila *F, telem *valor); int remover (tfila *F, telem valor); tfila NUMEROS; int opcao; main() { int fim=0; criar (&NUMEROS); do { printf(" EDITOR DE FILA\n"); printf("\n1 - ADICIONAR\n"); printf("\n2 - EXCLUIR\n"); printf("\n3 - EXIBIR PRIMEIRO ELEMENTO\n"); printf("\n4 - EXIBIR FILA\n"); printf("\n5 - ESVAZIAR\n"); printf("\n6 - SAIR\n"); printf("nDIGITE SUA OPCAO:"); scanf("%d", &opcao); system("cls"); switch (opcao) { case 1:ADICIONAR(); break; case 2:EXCLUIR(); break; case 3:EXIBIRPRIMEIROELEMENTO(); break; case 4:EXIBIRFILA(); break; case 5:ESVAZIAR(); break; case 6:fim=1; break; default: printf("Opcao invalida\n"); getch(); } }while (!(fim)); printf("Programa encerrado"); getch(); } void ADICIONAR() { /* telem num; system("cls"); printf(" ADICIONAR DADOS\n"); printf("Digite um numero inteiro: (zero para terminar):"); scanf("%d",&num); while(!(num==0)) { if (!(inserir (&NUMEROS,tamanho(NUMEROS)+1,num))) { printf("NUMERO MAXIMO DE DADOS ATINGIDO"); getch(); return; } printf("Digite um numero inteiro: (zero para terminar):"); scanf("%d",&num); }*/ } void EXCLUIR() { /*telem num; int posicao; system("cls"); printf(" E X C L U I R D A D O\n"); printf("Digite posicao de exclusao:"); scanf("%d", &posicao); if (!(remover (&inicio, &final))) { printf("FILA VAZIA"); getch(); return; } else { printf("O numero %d foi excluido da lista.", num); } getch();*/ } void EXIBIRPRIMEIROELEMENTO () { /* telem num; system("cls"); if (elem(NUMEROS, &fila)) { printf("VALOR DO INICIO: %d\n", num); getch(); } else { printf("Nenhum numero inserido\n"); getch(); }*/ } void EXIBIRFILA() { /* system ("cls"); int i; if(NUMEROS.inicio == -1) printf("FILA VAZIA\n"); else { printf("FILA: "); for(i=0; i<=NUMEROS.fila; i++) printf("%d ", NUMEROS.v); printf("\n"); } getch();*/ } void ESVAZIAR() { } void criar (tfila *F) { F-> inicio = 0; F->final = -1; } int vazia (tfila F) { return (F.inicio > F.final); } int primeiro (tfila F, telem *dado) { if (vazia (F)) return 0; /* Erro fila vazia */ *dado = F.v[F.inicio]; return (1); } int inserir (tfila *F, telem *valor) { if (F->final == MAX-1) return 0; (F->final) ++; F->v[F->final]; return(1); } int remover (tfila *F, telem valor) { if (vazia (*F)) return 0; /* Erro: fila vazia */ int primeiro (tfila F, telem *dado); (F->inicio)++; return(1); } /* void imprimir (tfila *P) { }*/
  3. Foi feito em sala de aula, pode me informar a outra forma como você mencionou? adicionado 4 minutos depois O código não esta rodando, pode me mostrar como fazer tudo dentro das outras? Por exemplo: EMPILHAR no push, DESEMPILHAR no pop, EXIBIRELEMENTOTOPO no elementopo #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void MenuPrincipal(); void EMPILHAR(); void DESEMPILHAR(); void EXIBIRELEMENTODOTOPO(); void EXIBIRPILHA(); void ESVAZIAR(); #define MAX 3 typedef int telem; typedef struct { telem v[MAX]; int topo; } tpilha; int menu(); void criar (tpilha *P); int vazia (tpilha P); int cheia (tpilha P); int tamanho (tpilha P); int elemtopo (tpilha P, telem *dado); int push (tpilha *P, telem dado); int pop (tpilha *P, telem dado); void imprimir (tpilha *P); tpilha NUMEROS; int opcao; main() { int fim=0; criar (&NUMEROS); do { MenuPrincipal(); switch (opcao) { case 1:EMPILHAR(); break; case 2:DESEMPILHAR(); break; case 3:EXIBIRELEMENTODOTOPO(); break; case 4:EXIBIRPILHA(); break; case 5:ESVAZIAR(); break; case 0:fim=1; break; default: printf("Opcao invalida\n"); getch(); } }while (!(fim)); printf("Programa encerrado"); getch(); } void MenuPrincipal() { system ("cls"); printf("EDITOR DE PILHA\n"); printf("\n1 - EMPILHAR\n"); printf("\n2 - DESEMPILHAR\n"); printf("\n3 - EXIBIR ELEMENTO DO TOPO\n"); printf("\n4 - EXIBIR PILHA\n"); printf("\n5 - ESVAZIAR\n"); printf("\n6 - SAIR\n"); scanf("%d",&opcao); } void EMPILHAR() { telem num; system("cls"); printf("EMPILHAR DADOS\n"); printf("Digite um numero inteiro:"); scanf("%d",&num); if (!(push (&NUMEROS,num))) { printf("NUMERO MAXIMO DE ELEMENTOS INSERIDOS"); getch(); return; } else { printf("DADO INSERIDO COM SUCESSO\n"); getch(); } } void DESEMPILHAR() { telem num; system("cls"); if (pop(&NUMEROS, &num)) { printf("VALOR RETIRADO: %d\n", num); getch(); } else { printf("PILHA VAZIA\n"); getch(); } } void EXIBIRELEMENTODOTOPO() { telem num; system("cls"); if (elemtopo(NUMEROS, &num)) { printf("VALOR DO TOPO: %d\n", num); getch(); } else { printf("PILHA VAZIA\n"); getch(); } } void EXIBIRPILHA() { system ("cls"); int i; if(NUMEROS.topo == -1) printf("PILHA VAZIA\n"); else { printf("PILHA: "); for(i=0; i<=NUMEROS.topo; i++) printf("%d ", NUMEROS.v); printf("\n"); } getch(); } void ESVAZIAR() { system ("cls"); NUMEROS.topo = -1; printf("PILHA ESVAZIADA COM SUCESSO\n"); getch(); } int remover (tpilha *P, int pos, telem *dado) { int i; if ((pos > P->topo) || (pos <=0)) return (0); *dado = P->v[pos-1]; for (i=pos; i<=(P->topo)-1; i++) P->v[i-1] = P->v; (P->topo)--; return(1); } void criar (tpilha *p) { p->topo= -1; } int vazia (tpilha P) { return (P.topo == -1); } int elemtopo (tpilha P, telem *dado) { if (vazia(P)) return 0; *dado =P.v[P.topo]; return 1; } int push (tpilha *p, telem dado) { if (p->topo == MAX-1) return 0; p->v[++p->topo] = dado; return 1; } int pop (tpilha *p, telem *dado) { if (vazia(*p)) return 0; *dado = p->v[p->topo--]; return 1; }
  4. Onde esta destacado em vermelho estou com dificuldades para terminar pode me ajudar? Só falta isso para estar completo. #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void MenuPrincipal(); void EMPILHAR(); void DESEMPILHAR(); void EXIBIRELEMENTODOTOPO(); void EXIBIRPILHA(); void ESVAZIAR(); #define MAX 3 typedef int telem; typedef struct { telem v[MAX]; int topo; } tpilha; int menu(); void criar (tpilha *P); int vazia (tpilha P); int cheia (tpilha P); int tamanho (tpilha P); int elemtopo (tpilha P, telem *dado); int push (tpilha *P, telem dado); int pop (tpilha *P, telem dado); void imprimir (tpilha *P); tpilha NUMEROS; int opcao; main() { int fim=0; criar (&NUMEROS); do { MenuPrincipal(); switch (opcao) { case 1:EMPILHAR(); break; case 2:DESEMPILHAR(); break; case 3:EXIBIRELEMENTODOTOPO(); break; case 4:EXIBIR PILHA(); break; case 5:ESVAZIAR(); break; case 0:fim=1; break; default: printf("Opcao invalida\n"); getch(); } }while (!(fim)); printf("Programa encerrado"); getch(); } void MenuPrincipal() { system ("cls"); printf("EDITOR DE PILHA\n"); printf("\n1 - EMPILHAR\n"); printf("\n2 - DESEMPILHAR\n"); printf("\n3 - EXIBIR ELEMENTO DO TOPO\n"); printf("\n4 - EXIBIR PILHA\n"); printf("\n5 - ESVAZIAR\n"); printf("\n6 - SAIR\n"); scanf("%d",&opcao); } void EMPILHAR() { telem num; system("cls"); printf("EMPILHAR DADOS\n"); printf("Digite um numero inteiro:"); scanf("%d",&num); if (!(push (&NUMEROS,num))) { printf("NUMERO MAXIMO DE ELEMENTOS INSERIDOS"); getch(); return; } else { } } void DESEMPILHAR() { } int remover (tpilha *P, int pos, telem *dado) { int i; if ((pos > P->topo) || (pos <=0)) return (0); *dado = P->v[pos-1]; for (i=pos; i<=(P->topo)-1; i++) P->v[i-1] = P->v; (P->topo)--; return(1); } void criar (tpilha *p) { p->topo= -1; } int vazia (tpilha P) { return (P.topo == -1); } int elemtopo (tpilha P, telem *dado) { if (vazia(P)) return 0; *dado =P.v[P.topo]; return 1; } int push (tpilha *p, telem dado) { if (p->topo == MAX-1) return 0; p->v[++p->topo] = dado; return 1; } int pop (tpilha *p, telem *dado) { if (vazia(*p)) return 0; *dado = p->v[p->topo--]; return 1; }
  5. Rodou porque comentei o erro. case 3:EXIBIR ELENTO DO TOPO PILHA(); break; case 4:IMPRIMIR PILHA(); break; case 5:ESVAZIAR(); break;*/ Falta o Else do void Empilhar else { } e void desempilhar void DESEMPILHAR() { }
  6. Estou tendo problemas com código abaixo poderiam me ajudar a ver onde estou errando??? Ta rodando no Dev C++, porém não esta completo. #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void MenuPrincipal(); void EMPILHAR(); void DESEMPILHAR(); void EXIBIRELEMENTODOTOPO(); void EXIBIRPILHA(); void ESVAZIAR(); #define MAX 3 typedef int telem; typedef struct { telem v[MAX]; int topo; } tpilha; void criar (tpilha *P); int vazia (tpilha P); int cheia (tpilha P); int tamanho (tpilha P); int elemtopo (tpilha P, telem *dado); int push (tpilha *P, telem dado); int pop (tpilha *P, telem dado); void imprimir (tpilha *P); tpilha NUMEROS; int opcao; main() { int fim=0; criar (&NUMEROS); do { MenuPrincipal(); switch (opcao) { case 1:EMPILHAR(); break; case 2:DESEMPILHAR(); break;/* case 3:EXIBIRELEMENTODOTOPO(); break; case 4:EXIBIR PILHA(); break; case 5:ESVAZIAR(); break;*/ case 6:fim=1; break; default: printf("Opcao invalida\n"); getch(); } }while (!(fim)); printf("Programa encerrado"); getch(); } void MenuPrincipal() { system ("cls"); printf("EDITOR DE PILHA\n"); printf("\n1 - EMPILHAR\n"); printf("\n2 - DESEMPILHAR\n"); printf("\n3 - EXIBIR ELEMENTO DO TOPO\n"); printf("\n4 - EXIBIR PILHA\n"); printf("\n5 - ESVAZIAR\n"); printf("\n6 - SAIR\n"); scanf("%d",&opcao); } void EMPILHAR() { telem num; system("cls"); printf("EMPILHAR DADOS\n"); printf("Digite um numero inteiro:"); scanf("%d",&num); if (!(push (&NUMEROS,num))) { printf("NUMERO MAXIMO DE ELEMENTOS INSERIDOS"); getch(); return; } else { } } void DESEMPILHAR() { } int remover (tpilha *P, int pos, telem *dado) { int i; if ((pos > P->topo) || (pos <=0)) return (0); *dado = P->v[pos-1]; for (i=pos; i<=(P->topo)-1; i++) P->v[i-1] = P->v; (P->topo)--; return(1); } void criar (tpilha *p) { p->topo= -1; } int vazia (tpilha P) { return (P.topo == -1); } int elemtopo (tpilha P, telem *dado) { if (vazia(P)) return 0; *dado =P.v[P.topo]; return 1; } int push (tpilha *p, telem dado) { if (p->topo == MAX-1) return 0; p->v[++p->topo] = dado; return 1; } int pop (tpilha *p, telem *dado) { if (vazia(*p)) return 0; *dado = p->v[p->topo--]; return 1; } adicionado 1 minuto depois Preciso de ajuda nessa implementação. adicionado 1 minuto depois preciso de ajuda nessa implementação

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...