Vous êtes sur la page 1sur 9

#include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.

h> int seleccionado; char cadenaReporte[10000] = "\n\n===========================REPORTE============= ===============\n\n========================TABLA DETALLES======================= =\n\nMATERIAL TIPO ESPESOR CUCHILLA CORTE\n\n========================== ====================================\n\n"; void menuPrincipal(); void menuTipoAcero(); void menuEspesoresAcero(int tipo); void menuTipoAluminio(); void menuEspesoresAluminio(int tipo); void void void void void void void void void menuDeseaCortar(int tipo, double espesor, char material); menuCuchillaEstandar(int tipo, double espesor, char material); comparaCuchillaEstandar(int tipo, double espesor, char material); menuPreCalibracion(int tipo, double espesor, char material); menuCalibracion(int tipo, double espesor, char material); escribeMensaje(char material[9], int tipo, double espesor, char corte[50]); menuDeseaCortarOtroMaterial(); compara(int tipo, double espesor, char material, char tipoCuchilla); salir();

int buenos; int materialDesperdiciado; //las estructuras struct aluminio { int tipo; double espesor[7]; } t10, t12, t14; struct acero { int tipo; double espesor[6]; } t304, t430; void main() { t304.tipo = 304; t430.tipo = 430; t10.tipo = 10; t12.tipo = 12; t14.tipo = 14; menuPrincipal(); buenos = 0; materialDesperdiciado = 0; } /*

Menu principal */ void menuPrincipal() { seleccionado = -1; while (seleccionado < 1 seleccionado > 3) { clrscr(); printf("Que material desea cortar?\n1) Acero Inoxidable\ n2) Aluminio\n3) Salir\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } switch (seleccionado) { case 1: menuTipoAcero(); break; case 2: menuTipoAluminio(); break; case 3: salir(); break; default: break; } }

/* para el acero */ void menuTipoAcero() { seleccionado = -1; while (seleccionado < 1 seleccionado > 2) { clrscr(); printf("Seleccione el tipo de acero\n1) 304\n2) 430\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } switch (seleccionado) { case 1: menuEspesoresAcero(t304.tipo); break; case 2: menuEspesoresAcero(t430.tipo); break; default: break; } } void menuEspesoresAcero(int tipo) { seleccionado = -1; while (seleccionado < 1 seleccionado > 6) {

clrscr(); printf("Seleccione el espesor\n1) 0.5mm\n2) 0.75mm\n3) 1mm\n4) 1 .5mm\n5) 2mm\n6) 2.5mm\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } double espesor = 0.0; switch (seleccionado) { case 1: espesor = 0.5; break; case 2: espesor = 0.75; break; case 3: espesor = 1.0; break; case 4: espesor = 1.5; break; case 5: espesor = 2.0; break; case 6: espesor = 2.5; break; default: break; } menuDeseaCortar(tipo, espesor, 'c'); }

/* para el aluminio */ void menuTipoAluminio() { seleccionado = -1; while (seleccionado < 1 seleccionado > 3) { clrscr(); printf("Seleccione el tipo de aluminio\n1) H10\n2) H12\n3) H14\n Opcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } switch (seleccionado) { case 1: menuEspesoresAluminio(t10.tipo); break; case 2: menuEspesoresAluminio(t12.tipo); break; case 3: menuEspesoresAluminio(t14.tipo);

break; default: break; } } void menuEspesoresAluminio(int tipo) { seleccionado = -1; while (seleccionado < 1 seleccionado > 7) { clrscr(); printf("Seleccione el espesor\n1) 0.75mm\n2) 1mm\n3) 1.5mm\n4) 2 mm\n5) 2.5mm\n6) 3mm\n7) 3.5mm\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } double espesor = 0.0; switch (seleccionado) { case 1: espesor = 0.75; break; case 2: espesor = 1.0; break; case 3: espesor = 1.5; break; case 4: espesor = 2.0; break; case 5: espesor = 2.5; break; case 6: espesor = 3.0; break; case 7: espesor = 3.5; break; default: break; } menuDeseaCortar(tipo, espesor, 'l'); } /** para todos **/ void menuDeseaCortar(int tipo, double espesor, char material) { seleccionado = -1; while (seleccionado < 1 seleccionado > 2) { clrscr(); printf("Desea cortar el material?\n1) si\n2) no\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); }

switch (seleccionado) { case 1: comparaCuchillaEstandar(tipo, espesor, material); break; case 2: menuPrincipal(); break; default: break; } } void comparaCuchillaEstandar(int tipo, double espesor, char material) { int ok = 0; if (material == 'c') { if (espesor >= 1.0 && espesor <= 2.0) { buenos++; escribeMensaje("ACERO ", tipo, espesor, " ESTANDAR BUENO\n"); ok = 1; } } else { if (espesor >= 1.0 && espesor <= 3.0) { buenos++; escribeMensaje("ALUMINIO ", tipo, espesor, " ESTANDAR BUENO\n"); ok = 1; } } if (ok == 0) { menuPreCalibracion(tipo, espesor, material); } } void menuPreCalibracion(int tipo, double espesor, char material) { seleccionado = -1; while (seleccionado < 1 seleccionado > 2) { clrscr(); printf("No cumple las condiciones de cuchilla para este material \nDesea cortar de todas maneras?\n1) si\n2) no\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } switch (seleccionado) { case 1: if (material == 'c') { materialDesperdiciado++; escribeMensaje("ACERO ", tipo, espesor, " ESTANDAR MATERIAL DESPERDICIADO\n"); } else { ESTANDAR materialDesperdiciado++; escribeMensaje("ALUMINIO ", tipo, espesor, " MATERIAL DESPERDICIADO\n");

} break; case 2: menuCalibracion(tipo, espesor, material); break; default: break; } } void menuCalibracion(int tipo, double espesor, char material) { seleccionado = -1; while (seleccionado < 1 seleccionado > 2) { clrscr(); printf("Menu de calibracion, desea\n1) Ajustar Cuchilla\n2) Aflo jar cuchilla\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } switch (seleccionado) { case 1: compara(tipo, espesor, material, 'j'); break; case 2: compara(tipo, espesor, material, 'f'); break; default: break; } } void compara(int tipo, double espesor, char material, char tipoCuchilla) { //para acero if (material == 'c') { if (tipoCuchilla == 'j') { if (espesor < 1.0) { buenos++; escribeMensaje("ACERO ", tipo, espesor, " AJUSTE CUCHILLA BUENO\n"); } else { AJUSTE CUCHILLA materialDesperdiciado++; escribeMensaje("ACERO ", tipo, espesor, " MATERIAL DESPERDICIADO\n"); } } else { if (espesor > 2.0) { buenos++; escribeMensaje("ACERO BUENO\n"); } else { materialDesperdiciado++; escribeMensaje("ACERO ", tipo, espesor, " ", tipo, espesor, "

AFLOJE CUCHILLA

AFLOJE CUCHILLA } } else {

MATERIAL DESPERDICIADO\n"); }

if (tipoCuchilla == 'j') { if (espesor < 1.0) { buenos++; escribeMensaje("ALUMINIO ", tipo, espesor, " AJUSTE CUCHILLA BUENO\n"); } else { AJUSTE CUCHILLA materialDesperdiciado++; escribeMensaje("ALUMINIO ", tipo, espesor, " MATERIAL DESPERDICIADO\n"); } } else { if (espesor > 3.0) { buenos++; escribeMensaje("ALUMINIO ", tipo, espesor, " BUENO\n"); } else { materialDesperdiciado++; escribeMensaje("ALUMINIO ", tipo, espesor, " MATERIAL DESPERDICIADO\n"); } } } } void menuDeseaCortarOtroMaterial() { seleccionado = -1; while (seleccionado < 1 seleccionado > 2) { clrscr(); printf("Seleccione una opcion?\n1) Cortar otro material\n2) Term inar el corte\nOpcion.... "); getch(); char aux[256]; gets(aux); seleccionado = atoi(aux); } switch (seleccionado) { case 1: menuPrincipal(); break; case 2: salir(); break; default: break; } } void escribeMensaje(char material[9], int tipo, double espesor, char corte[50]) { strcat(cadenaReporte, material); char numero[10];

AFLOJE CUCHILLA

AFLOJE CUCHILLA

itoa(tipo, numero, 10); if (material[1] == 'L') { strcat(cadenaReporte, "H"); } strcat(cadenaReporte, numero); strcat(cadenaReporte, " "); char espesorc[10]; sprintf(espesorc, "%1.2f", espesor); strcat(cadenaReporte, espesorc); strcat(cadenaReporte, corte); menuDeseaCortarOtroMaterial(); } void salir() { strcat(cadenaReporte, "\n====================TABLA RESUMEN CORTES======= ==============="); strcat(cadenaReporte, "\n BUENO MALO TOTAL"); strcat(cadenaReporte, "\n CORTES "); char numero[10]; itoa(buenos, numero, 10); strcat(cadenaReporte, numero); strcat(cadenaReporte, " ");

itoa(materialDesperdiciado, numero, 10); strcat(cadenaReporte, numero); strcat(cadenaReporte, " "); int totalCortes = buenos + materialDesperdiciado; itoa(totalCortes, numero, 10); strcat(cadenaReporte, numero); strcat(cadenaReporte, "\n PORCEN "); double porcen = (double) buenos / totalCortes; porcen *=100.0; char espesorc[10]; sprintf(espesorc, "%1.2f", porcen); strcat(cadenaReporte, espesorc); strcat(cadenaReporte, " ");

porcen = (double) materialDesperdiciado / totalCortes; porcen *=100.0; sprintf(espesorc, "%1.2f", porcen); strcat(cadenaReporte, espesorc); strcat(cadenaReporte, "\n=======================FIN DEL REPORTE========= ==============="); FILE *fp; fp = fopen("reporte.txt", "w"); fprintf(fp, cadenaReporte);

fclose (fp); clrscr(); printf(cadenaReporte); getch(); getch(); }

Vous aimerez peut-être aussi