Buscar

ATPS Programação Estruturada II

Prévia do material em texto

Disciplina: Programação Estruturada II 
 
 
ATPS 
 
 
 
 
NOME Yago Lau Pereira Guerra 
RA 7092574716 
 
 
NOME Alex Sander Lima da Silva Junior 
RA 7632731330 
 
 
NOME Jahuan Christian da Silva 
RA 2289524340 
 
 
 
 
 
Anhanguera Educacional 
2014 
 
 
 
 
 
 
 
 
 
#define ANO_ATUAL 2014 
#define TOTAL_CANDIDATOS 10 
#define TOTAL_DISCIPLINAS 5 
#define TOTAL_CRITERIOS 6 
 
// Structs 
typedef struct { 
 char Nome[20]; 
 char Email[45]; 
 int NotaFinal; 
} Candidato; 
 
typedef struct { 
 int ProgEstrutI; 
 int ProgEstrutII; 
 int ProgOrientObjI; 
 int ProgOrientObjII; 
 int ProgConcorrente; 
} MediaDisciplina; 
 
typedef struct { 
 int ExpProg; 
 int ConhecimentoAlg; 
 int ConhecimentoUML; 
 int ConhecimentoBancoDados; 
 int CertJava; 
 int MediaGeral; 
} Criterio; 
 
// Matrizes 
 
 
int NotasConceitos[TOTAL_DISCIPLINAS] = { 
 10, 
 7, 
 5, 
 3, 
 0 
}; 
 
int NotasDisciplinas[TOTAL_DISCIPLINAS] = { 
 5, 
 10, 
 15, 
 20, 
 25 
}; 
 
char NomeDisciplinas[TOTAL_DISCIPLINAS][40] = { 
 "Programacao Estruturada I", 
 "Programacao Estruturada II", 
 "Programacao Orientada a Objetos I", 
 "Programacao Orientada a Objetos II", 
 "Programacao Concorrente" 
}; 
 
int main (){ 
 
 Criterio c; 
 MediaDisciplina m; 
 Candidato candidatos[TOTAL_CANDIDATOS]; 
 int i; 
 int NotaFinalCandidatos[TOTAL_CANDIDATOS] = {}; 
 
 for (i=0; i < TOTAL_CANDIDATOS; i++){ 
 // Regra de Negócio 8 
 
 
 
 printf ("Informe seu nome: "); 
 scanf ("%s", &candidatos[i].Nome); 
 printf ("Informe seu e-mail: "); 
 scanf ("%s", &candidatos[i].Email); 
 
 // Regra de Negócio 1 
 
 int Ano; 
 printf ("Informe o ano em que comecou a programar: "); 
 scanf ("%d", &Ano); 
 Ano = ANO_ATUAL - Ano; 
 if(Ano > 10) 
 { 
 c.ExpProg = 20; 
 } 
 else if(Ano > 5) 
 { 
 c.ExpProg = 10; 
 } 
 else 
 { 
 c.ExpProg = 5; 
 } 
 
 // Regra de Negócio 2 
 
 printf ("Informe seu nivel de experiencia em algoritmos numa escala de 1 a 5, 
sendo: "); 
 printf ( 
 "\r\n1 (Excelente) \ 
 \r\n2 (Muito Bom) \ 
 \r\n3 (Bom) \ 
 \r\n4 (Regular) \ 
 
 
 \r\n5 (Nenhum)\r\n" 
 ); 
 
 int ConheceAlg; 
 scanf ("%d", &ConheceAlg); 
 c.ConhecimentoAlg = NotasConceitos[ConheceAlg - 1]; 
 
 // Regra de Negócio 3 
 
 printf ("Informe seu nivel de experiencia em UML numa escala de 1 a 5, sendo: "); 
 printf ( 
 "\r\n1 (Excelente) \ 
 \r\n2 (Muito Bom) \ 
 \r\n3 (Bom) \ 
 \r\n4 (Regular) \ 
 \r\n5 (Nenhum)\r\n" 
 ); 
 
 int ConhecaUML; 
 scanf ("%d", &ConhecaUML); 
 c.ConhecimentoUML = NotasConceitos[ConhecaUML - 1]; 
 
 //Regra de Negócio 4 
 
 printf ("Informe seu nivel de experiencia em Banco de Dados numa escala de 1 a 
5, sendo: "); 
 printf ( 
 "\r\n1 (Excelente) \ 
 \r\n2 (Muito Bom) \ 
 \r\n3 (Bom) \ 
 \r\n4 (Regular) \ 
 \r\n5 (Nenhum)\r\n" 
 ); 
 
 
 
 int ConheceDB; 
 scanf ("%d", &ConheceDB); 
 c.ConhecimentoBancoDados = NotasConceitos[ConheceDB - 1]; 
 
 //Regra de Negócio 5 
 
 int Certificados; 
 printf ("Informe quantos certificados JAVA voce possui: "); 
 scanf ("%d", &Certificados); 
 
 if(Certificados == 1) 
 { 
 c.CertJava = 10; 
 } 
 else if(Certificados == 2) 
 { 
 c.CertJava = 20; 
 } 
 else 
 { 
 c.CertJava = 25; 
 } 
 
 //Regra de Negócio 6 
 
 printf("Digite a media (inteira) para as seguintes disciplinas:\r\n"); 
 int d; 
 int *p_disciplinas; 
 p_disciplinas = (int*)&m; 
 
 for(d = 0; d < TOTAL_DISCIPLINAS; d ++) 
 { 
 int Nota; 
 printf("%s: ", NomeDisciplinas[d]); // Printa disciplinas de acordo com a matriz 
 
 
 scanf("%d", &Nota); // atribui valores aos membros da struct de acordo com a 
matriz 
 if(Nota <= 5) 
 { 
 *(p_disciplinas+d) = 0; 
 } 
 else if(Nota > 10) 
 { 
 *(p_disciplinas+d) = 25; 
 } 
 else 
 { 
 *(p_disciplinas+d) = NotasDisciplinas[Nota - 6]; 
 } 
 } 
 //printf("%d \r\n", CalcMediaStruct(m, TOTAL_DISCIPLINAS)); 
 c.MediaGeral = CalcMediaDisciplinas(m); 
 
 //Regra de Negócio 7 
 candidatos[i].NotaFinal = CalcMediaCriterios(c); 
 printf("Sua media consolidada: %d \r\n\r\n\r\n", candidatos[i].NotaFinal); 
 NotaFinalCandidatos[i] = candidatos[i].NotaFinal; 
 } 
 // Regra de Negócio 8 
 
 int candidato = MaiorNota(NotaFinalCandidatos); 
 printf("\n\n\nCandidato com maior nota: \n\n"); 
 printf("Nome: %s\n", candidatos[candidato].Nome); 
 printf("Email: %s\n", candidatos[candidato].Email); 
 printf("Nota: %d\n", candidatos[candidato].NotaFinal); 
 return 0; 
} 
 
int CalcMediaCriterios(c) 
 
 
{ 
 int *p_criterios; 
 p_criterios = (int*)&c; 
 
 int i; 
 int soma_notas = 0; 
 
 for(i = 0; i < TOTAL_CRITERIOS; i ++) 
 { 
 soma_notas += *(p_criterios+i); 
 } 
 return soma_notas / TOTAL_CRITERIOS; 
} 
 
int CalcMediaDisciplinas(m) 
{ 
 int *p_disciplinas; 
 p_disciplinas = (int*)&m; 
 
 int i; 
 int soma_notas = 0; 
 
 for(i = 0; i < TOTAL_DISCIPLINAS; i ++) 
 { 
 soma_notas += *(p_disciplinas+i); 
 } 
 return soma_notas / TOTAL_DISCIPLINAS; 
} 
 
int MaiorNota(int notas[]) 
{ 
 int i, max = 0, candidato_max = -1; 
 for(i = 0; i < TOTAL_CANDIDATOS; i++) 
 { 
 
 
 if(notas[i] > max) 
 { 
 max = notas[i]; 
 candidato_max = i; 
 } 
 } 
 return candidato_max; 
}

Continue navegando