Ir ao conteúdo
  • Cadastre-se

Wesley Kelson

Membro Júnior
  • Posts

    5
  • Cadastrado em

  • Última visita

Reputação

0
  1. Simples e rápido obrigado a todos vocês, pelas dicas e pela compreensão
  2. Tenho outro problema rsrs como minha variavel para opção do menu é inteira qualquer letra ou simbolo fecha meu programa, alguem tem uma sugestão de como mudar isso, string e char não recebem valores numericos.
  3. Realmente obrigado ajudou bastante...refiz minha logica tendo em vista o que você disse, agora o programa parece estar da maneira certa. segue ele abaixo, me agornizei melhor desta vez Program Fazenda ;uses Crt; //VARIÁVEIS DO PROGRAMAVaropcao, i, pesquisaBoi, contaCadastrados: integer ;identidades: Array [1..100] of integer ;pesos: Array [1..100] of Real ;racas: Array [1..100] of string ;boiEncontrado: Boolean ;exibeDados, confirmaExclusao, continuaCadastro : char;//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------BeginClrscr ;opcao := 0 ;While (opcao <> 5)Do Begin Begin clrscr; Writeln ('ESCOLHA A OPÇÃO DESEJADA:') ; Writeln ('1 - INSERIR BOIS') ; Writeln ('2 - EXIBIR BOIS CADASTRADOS') ; //MENU PRINCIPAL Writeln ('3 - PESQUISAR BOI') ; Writeln ('4 - EXCLUIR BOI') ; Writeln ('5 - SAIR') ; writeln ('ATENCAO: LIMITE DE BOIS A SEREM CADASTRADOS É DE 100.'); end ; Readln (opcao) ;//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Case opcao of 1: begin continuaCadastro := 'S'; while ((i >= 1) and (i <= 100) and (continuaCadastro = 's') or (continuaCadastro = 'S')) do begin clrscr; i := i+1; Writeln ('DIGITE A IDENTIDADE DO ', i, 'o BOI.' ) ; Readln (identidades[i]) ; Writeln ('DIGITE O PESO DO ', i, 'o BOI.') ; //INSERIR BOIS Readln (pesos[i]) ; Writeln ('DIGITE A RACA DO ', i, 'o BOI.') ; readln (racas[i]) ; contaCadastrados := contaCadastrados + 1; if i = 100 then begin continuaCadastro := 'n'; end else begin writeln ('DESEJA CADASTRAR MAIS UM BOI? (S/N)'); readln(continuaCadastro); end; end; end; //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2: begin if contaCadastrados = 0 then begin clrscr; writeln('NENHUM BOI CADASTRADO ATÉ O MOMENTO.'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end else begin clrscr; writeln('DADOS DOS BOIS CADASTRADOS:'); writeln(i); For i :=1 to contaCadastrados do Begin writeln('#. BOI: ',i); writeln('ID.: ',identidades[i]); writeln('PESO: ', pesos[i]:0:2,' Kg'); // EXIBIR BOIS writeln('RAÇA: ', racas[i]); writeln(i); end; Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end; end;//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 3: Begin if contaCadastrados = 0 then begin clrscr; writeln('NENHUM BOI CADASTRADO ATÉ O MOMENTO.'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end else begin clrscr; writeln ('DIGITE O N. DE ID. DO BOI A SER PESQUISADO:'); readln(pesquisaboi); boiEncontrado := false; for i := 1 to contaCadastrados do begin if identidades[i] = pesquisaBoi then //PESQUISAR BOIS begin writeln('BOI ID. ', identidades[i], ' ENCONTRADO:'); boiEncontrado := true; readkey; writeln('ID.: ',identidades[i]); writeln('PESO: ', pesos[i]:0:2,' Kg'); writeln('RAÇA: ', racas[i]); readkey; end; end; if boiEncontrado = false then begin writeln('BOI NÃO CADASTRADO COM ESSE ID.'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end; end; end;//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 4: Begin if contaCadastrados = 0 then begin clrscr; writeln('NENHUM BOI CADASTRADO ATÉ O MOMENTO.'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end else begin clrscr; writeln ('DIGITE O N. DE ID. DO BOI A SER EXCLUIDO:'); readln(pesquisaboi); for i := 1 to contaCadastrados do begin boiEncontrado := false; if identidades[i] = pesquisaBoi then begin boiEncontrado := true; writeln('BOI ID. ', identidades[i], ' ENCONTRADO.'); //EXCLUIR BOIS writeln('EXIBIR DADOS? (S/N)'); readln(exibeDados); if (exibeDados = 'S') or (exibeDados = 's') then begin writeln('ID.: ',identidades[i]); writeln('PESO: ', pesos[i]:0:2,' Kg'); writeln('RAÇA: ', racas[i]); readkey; writeln('DESEJA REALMENTE EXCLUIR ESSE BOI? (S/N)'); readln(confirmaExclusao); if (confirmaExclusao = 'S') or (confirmaExclusao = 's') then begin identidades[i]:= 0; pesos[i] := 0; racas[i] := ''; writeln('BOI EXCLUIDO COM SUCESSO!'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end else begin opcao := 0; end; end else begin writeln('DESEJA REALMENTE EXCLUIR ESSE BOI? (S/N)'); readln(confirmaExclusao); if (confirmaExclusao = 'S') or (confirmaExclusao = 's') then begin identidades[i]:= 0; pesos[i] := 0; racas[i] := ''; writeln('BOI EXCLUIDO COM SUCESSO!'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end; opcao := 0; end; end; end; if boiEncontrado = false then begin writeln('NENHUM BOI CADASTRADO COM ESSE ID.'); Writeln ('PRESSIONE QUALQUER TECLA PARA VOLTAR AO MENU.'); readkey; end; end; end; end;end; End.
  4. Olá meus caros, Estou ingressando nesse maravilhoso mundo da tecnologia e informação, estou fazendo um curso tecnico em um instuto federal na Bahia, desejo a quem me lê um otimo dia tarde ou noite : ) MAS...meu problema, me foi pedido um trabalho onde eu tenha que desenvolver um programa que gerencie uma fazenda de gado, como não estou muito longe no curso, apenas no 1º semestre não me foi passado, nem tão pouco conheço de muitos artificios para desenvolver o programa, tendo em vista que esse era o plano do meu professor, desenvolver com o que sabemos, aprender e explicar a ele o que foi aprendido, pois bem começei o desenvolvimento do programa, porém ele apresenta varias falhas, listarei algumas e peço que se alguem puder me ajude por favor. 1º não consigo preencher um vetor um espaço por vez e sempre perguntanto ao usuario se ele deseja continuar ou voltar, preencho apenas de forma sequencial 2º não consigo realizar o processo de exclusão dentro do vetor 3º consigo apenas realizar uma busca existencial, o programa diz que existe mais nção me mostra o dado Segue aqui meu projeto Program Fazenda ;Var menu, menu2, contador, contador2, identidade: integer ; peso: Real ; raca,excluir : String ; identidades: Array [1..5] of integer ; pesos: Array [1..5] of Real ; racas: Array [1..5] of string ; encontrado: Boolean ; Begin Clrscr ; menu := 0 ; While (menu <> 5)Do Begin Begin Writeln ('Escolha a Opção') ; Writeln; Writeln ('1 - Inserir novo gado') ; Writeln ('2 - Exibir lista de gados') ; //Menu Operacional Writeln ('3 - Pesquisar Gado') ; Writeln ('4 - Excluir gado') ; Writeln ('5 - Sair do programa') ; end ; Writeln; Writeln ('Opção escolhida') ; Readln (menu) ; Case menu of 1:For contador := 1 to 5 do begin clrscr ; begin Writeln ('Digite a identidade do gado') ; Readln (identidades[contador]) ; Writeln ('Digite o Peso do gado') ; //Inclusão Readln (pesos[contador]) ; Writeln ('Digite a raça do gado') ; readln (racas[contador]) ; end; end; 2: For contador :=1 to 5 do Begin writeln (contador, ' : ' , ' Identidade ' , ' : ' , identidades[contador] ,' : ' ,' Peso ' , ' : ' , pesos[contador] , ' : ' ,' Raca ' , ' : ' , racas[contador]) ; //Pesquisa total end; 3:Begin clrscr ; writeln ('Escolha a Opção') ; writeln ('1 - pesquisar por identidade') ; writeln ('2 - Pesquisar por peso') ; writeln ('3 - Pesquisar por raça') ; Writeln ('Opção escolhida') ; Readln (menu2) ; encontrado := false ; contador:= 1 ; If (menu2 = 1) then begin writeln ('Digite a identidade a ser pesquisada') ; Readln (identidade) ; while ((contador <= 5) and (not encontrado)) do Begin If (identidades[contador] = identidade) then encontrado := true Else contador := (contador + 1) ; end ; If (encontrado = true) then begin Writeln (identidade, 'encontrada') ; Writeln (identidades[contador]) ; end Else Writeln (' Identidade não encontrada') ; //Pesquisa por item end; If (menu2 = 2) then begin writeln ('Digite o peso a ser pesquisado') ; Readln (peso) ; while ((contador <= 5) and (not encontrado)) do Begin If (pesos[contador] = peso) then encontrado := true Else contador := (contador + 1) ; end ; If (encontrado = true) then begin Writeln (peso, 'encontrado') ; end Else Writeln ('peso não encontrado') ; end; If (menu2 = 3) then begin writeln ('Digite a raça a ser pesquisada') ; Readln (raca) ; while ((contador <= 5) and (not encontrado)) do Begin Begin If (racas[contador] = raca) then encontrado := true Else contador := (contador + 1) ; end ; If (encontrado = true) then begin Writeln (raca, 'encontrada') ; end Else Writeln ('raça não encontrada') ; end; end; end; 4:begin writeln ('Digite a identidade a ser excluida') ; Readln (identidade) ; while ((contador <= 5) and (not encontrado)) do Begin If (identidades[contador] = identidade) then encontrado := true //exclusão Else contador := (contador + 1) ; end ; If (encontrado = true) then begin writeln ('deseja excluir?') ; If (excluir='sim') then identidades[contador]:=0 ; end ; end ; end; end; End. Se alguem poder me ajudar ficaria muito grato, obrigado Att wesley kelson estudando de tecnologia e informaçã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...