| Ver tema anterior :: Ver siguiente tema | | Autor | Mensaje |
|---|
sergio011295
Registrado: 24 Mar 2013 Mensajes: 1
| Publicado: 24/03/2013 2:03 pm | | | Título: Ayuda ejercicio c++ |
| Buenaas ! debo realizar el sgte ejercicio en devc++ pero no logro que funcione ¿puede alguien ayudarme a corregirlo Gracias ! https://word.office.live.com/wv/WordView.aspx?FBsrc=https%3A//www.facebook.com/download/file_preview.php%3Fid%3D598647393497860%26time%3D1364161466%26metadata&access_token=100001104991353%3AAVIx80klEYIIaSdLetlj883fDorKauTG-pwXKUi-5N055A&title=quiz4+subprogramas+y+condicionales-25.doc
Este es mi codigo
#include <cstdlib> #include <iostream> int servicio,promo; float total,des; char mp[10]; using namespace std; float agua() {int ca,est; float total,des; printf ("Consumo agua"); scanf ("%d",&ca); printf ("estrato"); scanf ("%d",&est); if (ca<=2000) return (total=35000); else if(ca>2000) return (total=35000+(ca-2000*400)); else if(est==1||est==2) des=total*0.20; return (total = total-des); if (est==3||est==4) des=total*0.10; return (total = total-des); } float energia() {int ce,est; float total,des; printf ("Consumo energia"); scanf ("%d",&ce); printf ("estrato"); scanf ("%d",&est); if (ce<=3000) return (total=30000); else if(ce>3000) return (total=30000+(ce-3000*350)); else if(est==1||est==2) des=total*0.15; return (total = total-des); if (est==3||est==4) des=total*0.10; return (total = total-des); if (est==5||est==6) des=total*0.05; return (total = total-des); } float telefono() {int ct,est; float total,des; printf ("Consumo telefono"); scanf ("%d",&ct); printf ("estrato"); scanf ("%d",&est); if (ct<=1000) return (total=38000); else if(ct>1000) return (total=38000+(ct-1000*100)); else if(est==1||est==2) des=total*0.30; return (total = total-des); if (est==3||est==4) des=total*0.12; return (total = total-des); if (est==5||est==6) des=total*0.08; return (total = total-des);
} int main(int argc, char *argv[]) {printf ("1.Agua\n2.Energia\n3.Telefono"); scanf ("%d",&servicio); printf ("Modo de pago (efectivo-Credito)"); scanf ("%s",&mp); switch (servicio) {case 1 : total =agua(); break; case 2 : total =energia(); break; case 3 : total =telefono(); break; default : printf ("Opcion no disponible\n"); break; } if (strcmp(mp,"efectivo")==0&&total>200000) {promo = (total*0.04); total = total-promo;} if (strcmp(mp,"credito")==0&&total>200000) {promo = (total*0.02); total = total-promo;}
printf ("El total es:%.0f",total);
system("PAUSE"); return EXIT_SUCCESS; } _________________ ss |
| | Volver arriba | |  | rir3760

Registrado: 01 Oct 2004 Mensajes: 7530 Ubicación: Mexico
| Publicado: 25/03/2013 9:34 am | | | Título: Re: Ayuda ejercicio c++ |
| Ese archivo no puede mostrarse correctamente, de todos modos lo que siempre se recomienda en estos casos es publicar el enunciado como texto plano.
En cuanto al programa faltan llaves en la funcion "agua":
| Código: | else if (est==1||est==2) des=total*0.20;
return (total = total-des); // <==
if (est==3||est==4) des=total*0.10;
return (total = total-des); // <== |
Mismo caso en las funciones "energia" y "telefono".
Un saludo _________________ C retains the basic philosophy that programmers know what they are doing; it only requires that they state their intentions explicitly. -- Kernighan & Ritchie, The C programming language |
| | Volver arriba | |  | | |
| No puede crear mensajes No puede responder temas No puede editar sus mensajes No puede borrar sus mensajes No puede votar en encuestas
|
|
| |