O códifo foi feito em C++ e consta com simular de troco de padaria, outro para verificar numeros inteiros, outro para verifica as notas de alunos e por último para calular salário de funcionário.
Espero que gostem e façam bom aproveito... e até a próxima matéria!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main(){
float au,si,sa,pts,pt;
char func[50];
int op,t,num;
int vap,vep,vt;
int rvt50,rvt20,rvt10,rvt5,rvt2,rvt1;
int vt50,vt20,vt10,vt5,vt2,vt1;
float nota;
char na[50];
char yn;
menu:
system("cls");
system("color 0a");
printf("%c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("%c Escolha uma das alternativas %c\n", 186,186);
printf("%c%c%c%c%c%c%c%c", 204,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,185);
printf("%c 1 -> Exercicio 01 %c\n",186,186);
printf("%c %c\n",186,186);
printf("%c 2 -> Exercicio 02 %c\n",186,186);
printf("%c %c\n",186,186);
printf("%c 3 -> Exercicio 03 %c\n",186,186);
printf("%c %c\n",186,186);
printf("%c 4 -> Exercicio 04 %c\n",186,186);
printf("%c %c\n",186,186);
printf("%c 5 -> Sair %c\n",186,186);
printf("%c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,188);
op:
printf("\n>>> ");
scanf("%d",&op);
switch(op){
case 1:
goto ex1;
case 2:
goto ex2;
case 3:
goto ex3;
case 4:
goto ex4;
case 5:
goto exit;
default:
system("color 0c");
system("cls");
printf("\n\n\n\n\n\n\n\n\t\t %c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("\t\t %c ESCOLHA UMA DAS ALTERNATIVAS %c\n", 186,186);
printf("\t\t %c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,188);
for(t=0;t<=800000000;t++);
goto menu;
}
ex1:
system("cls");
system("color 0d");
printf("\t\t %c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("\t\t %c Exercicio 1 %c\n", 186,186);
printf("\t\t %c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,188);
printf("\nDigite o valor a ser pago (em reais):(Ex.:1)\n>>> ");
scanf("%d",&vap);
printf("\nDigite o valor efetivamente pago(em reais):(Ex.:89)\n>>> ");
scanf("%d",&vep);
vt = vep-vap;
system("cls");
system("color 0b");
printf("... O troco %c de %d reais que pode ser distribuido na forma de:\n",130,vt);
if(vt>=50){
vt50=vt/50;
printf(" %1.d nota(s) de cinquenta reais\n",vt);
vt=vt%50;
}
if(vt>=20){
vt20=vt/20;
printf(" %1.d nota(s) de vinte reais\n",vt);
vt=vt%20;
}
if(vt>=10){
vt=vt/10;
printf(" %1.d nota(s) de dez reais\n",vt);
vt=vt%10;
}
if(vt>=5){
vt=vt/5;
printf(" %1.d nota(s) de cinco reais\n",vt);
vt=vt%5;
}
if(vt>=2){
vt=vt/2;
printf(" %1.d nota(s) de dois reais\n",vt);
vt=vt%2;
}
if(vt>=1){
printf(" %1.d nota(s) de um real\n",vt);
}
system("pause");
system("cls");
printf("Gostaria de verificar outro valor?\n Yes[Y] or Not[N]\n>>> ");
scanf("%s",&yn);
if ((yn=='Y') || (yn=='y')) goto ex1;
if ((yn=='N') || (yn=='n')) goto menu;
ex2:
system("cls");
system("color 0d");
printf("\t\t %c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("\t\t %c Exercicio 2 %c\n", 186,186);
printf("\t\t %c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,188);
printf("\nDigite um n%cmero inteiro qualquer:\n>>> ",163);
scanf("%d",&num);
if(num>0){
if((num % 2)==0){
system("cls");
system("color 0b");
printf("\n... O n%cmero %d %c um n%cmero par.\n (wait please)",163,num,130,163);
}
else{
system("cls");
system("color 0b");
printf("\n... O n%cmero %d %c um n%cmero impar.\n (wait please)",163,num,130,163);
}
}
else{
system ("cls");
system("color 0b");
printf("\n\nO n%cmero %d %c um n%cmero negativo.\n (wait please)",163,num,130,163);
}
for (t=0;t<=1000000000;t++);
system("cls");
printf("Gostaria de verificar outro numero?\n Yes[Y] or Not[N]\n>>> ");
scanf("%s",&yn);
if ((yn=='Y') || (yn=='y')) goto ex2;
if ((yn=='N') || (yn=='n')) goto menu;
ex3:
system("cls");
system("color 0d");
printf("\t\t %c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("\t\t %c Exercicio 3 %c\n", 186,186);
printf("\t\t %c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,188);
printf("\nDigite o nome do aluno:\n>>> ");
scanf("%s",&na);
printf("\nDigite a nota do aluno:\n>>> ",na);
scanf("%f",¬a);
system("cls");
system("color 0b");
if(nota<3) printf("\nO aluno %s obteve conceito E.\n(wait please)",na);
if((nota>=3)&&(nota<=5)) printf("\nO aluno %s obteve conceito D.\n(wait please)",na);
if((nota>=6)&&(nota<=7)) printf("\nO aluno %s obteve conceito C.\n(wait please)",na);
if((nota>=8)&&(nota<=9)) printf("\nO aluno %s obteve conceito B.\n(wait please)",na);
if(nota>9) printf("\nO aluno %s obteve conceito A.\n(wait please)",na);
for(t=0;t<=800000000;t++);
system("cls");
printf("Gostaria de verificar outro numero?\n Yes[Y] or Not[N]\n>>> ");
scanf("%s",&yn);
if ((yn=='Y') || (yn=='y')) goto ex3;
if ((yn=='N') || (yn=='n')) goto menu;
ex4:
menu_2:
system("cls");
system("color 0d");
printf("\t\t %c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("\t\t %c Exercicio 1 %c\n", 186,186);
printf("\t\t %c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,188);
printf("\n\tMenu principal\n");
printf("%c%c%c%c%c%c%c%c", 201,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,187);
printf("%c Escolha o que deseja fazer %c\n", 186,186);
printf("%c%c%c%c%c%c%c%c", 204,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n", 205,205,205,205,205,205,205,185);
printf("%c 1 -> Ver tabela de aumento %c\n",186,186);
printf("%c %c\n",186,186);
printf("%c 2 -> Verificar aumento %c\n",186,186);
printf("%c %c\n",186,186);
printf("%c 3 -> Sair %c\n",186,186);
printf("%c%c%c%c%c%c%c%c", 200,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c", 205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c\n>>> ", 205,205,205,205,205,205,205,188);
scanf("%d",&op);
switch(op){
case 1:
goto tabela;
case 2:
goto verificar;
case 3:
goto menu;
default:
system("cls");
system("color 0c");
printf("\n\n\n\n\t\tEscolha uma das alternativas apresentadas...");
for(t=1;t<=500000000;t++);
goto menu_2;
}
tabela:
system("cls");
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
printf("%c tabela da porcentagem de aumento %c\n",186,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,203,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c 0 - 400 %c 15%c %c\n",186,186,37,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,206,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c 401 - 700 %c 12%c %c\n",186,186,37,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,206,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c 701 - 1000 %c 10%c %c\n",186,186,37,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,206,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c 1001 - 1800 %c 7%c %c\n",186,186,37,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,206,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c 1801 - 2500 %c 4%c %c\n",186,186,37,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,206,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c Acima de 2500 %c sem aumento %c\n",186,186,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
system("pause");
goto menu_2;
verificar:
system("cls");
printf("Digite o nome do funcionario:\n>>> ");
scanf("%s",&func);
printf("Digite o salario atual do funcionario %s\n>>>", func);
scanf("%f",&si);
printf("Digite o valor do percentual de aumento no salario do funcinario %s\n>>>",func);
scanf("%f",&pt);
pts=(pt*si)/100;
sa= si+pts;
system("cls");
system("color 0b");
printf("O salario do funcionario %s sofrera um aumento de %.f %c\n(que corresponde a R$ %.2f) e passara a ser, de R$ %.2f para R$ %.2f\n",func,pt,37, pts,si,sa);
system("pause");
system("cls");
printf("Gostaria de verificar outro numero?\n Yes[Y] or Not[N]\n>>> ");
scanf("%s",&yn);
if ((yn=='Y') || (yn=='y')) goto ex4;
if ((yn=='N') || (yn=='n')) goto menu;
system("pause");
exit:
system("cls");
system("color 0a");
printf("\n\n\n\n\n\n\t\t\t Lista de exercios 2:\n\n");
printf("\t\t\tBy Daniel de Paiva Pereira.\n\n");
printf("\t\t\t Prof.: Agnus Horta");
for(t=0;t<=1000000000;t++);
return(0);
}
0 comentários:
Postar um comentário