sábado, 6 de octubre de 2012

practica 6

problema 1
codigo en c++:

# include <iostream.h>
# include <conio.h>
# include <stdio.h>
# include <dos.h>
int main ()
{
float p1,p2,p3,p4,p5,s_total,total,descuento;
int c1,c2,c3,c4,c5,si=2;
while (si==2)
{
cout<<" \t\ncantidad producto 1 =";
cin>>c1;
cout<<" \t\nprecio p1 =";
cin>>p1;
cout<<"\t\n cantidad producto 2 =";
cin>>c2;
cout<<" \t\nprecio p2 =";
cin>>p2;
cout<<" \t\ncantidad producto 3 =";
cin>>c3;
cout<<" \t\nprecio p3 =";
cin>>p3;
cout<<" \t\ncantidad producto 4 =";
cin>>c4;
cout<<" \n\tprecio p4 =";
cin>>p4;
cout<<" \t\ncantidad producto p5 =";
cin>>c5;
cout<<" \n\tprecio p5 =";
cin>>p5;
s_total=p1*c1+p2*c2+p3*c3+p4*c4+p5*c5;
cout<<" \n\tproducto   precio  subtotal ";
if (c1>0)
{
cout<<" porducto 1= "<<p1<<p1*c1<<endl;
}
if (c2>0)
{
cout<<" producto 2= "<<p2<<(p2*c2)<<endl;
}
if (c3>0)
{
cout<<" producto 3= "<<p3<<(p3*c3)<<endl;
}
if (c4>0)
{
cout<<" producto 4= "<<p4<<(p4*c4)<<endl;
}
if (c5>0)
{
cout<<" producto 5="<<p5<<(p5*c5)<<endl;
}
cout<<" el subtotal es ="<<s_total<<endl;
if (s_total>=500.0 && s_total<=1000.0)
{
descuento=s_total*0.03;
}
else{
if (s_total>=1001.0 && s_total<=7000.0)
{
descuento=s_total*0.06;
}
else{
if (s_total>=7001.0 && s_total<=15000.0)
{
descuento=s_total*0.12;
}
else {
if (s_total>15000.0)
{
descuento=s_total*0.20;
}
}
}
}
cout<<" el descuento es de ="<<descuento<<endl;
total=s_total-descuento;
cout <<" el total a pagar es de ="<<total<<endl;
cout<<"  para continuar presione 0 para salir y 2 para continuar"<<endl;

}
 {
 struct dosdate_t d;
 _dos_getdate(&d);
 printf("\n\n  fecha :   %d",d.day);
 printf(" / %d",d.month);
 printf(" / %d",d.year);
 }
getc
getch();
}



problema 2
codigo en c+

#include <iostream.h>
#include <conio.h>
int main()
{
float preciototal=0.0,p_basico=0.0 ,impuesto=0.0;
int n=2;
while (n==0)
{
cout<<"costo basico del articulo"<<endl;
cin>>p_basico;
if(p_basico>0&&p_basico<=20)
{
impuesto=0;
}
else
{
if(p_basico>20&&p_basico<40)
{
impuesto=0.30;
}
else
{
if (p_basico<500)
{
impuesto=p_basico*0.40;
}
else
{
if(p_basico>500)
{
impuesto=p_basico*0.50;
}
}
}
}
preciototal=p_basico+impuesto;
cout<<"preciototal="<<preciototal<<endl;
cout<<"coninuar 0 salir 1"<<endl;
}
getch();
}



pseudocodigo

inicio
Precio_total=0.0 real
Precio_basico=0.0 real
Impuesto=0.0 real
char sigue='s';
while(sigue=='s'||sigue=='S')
{
print"costo basico del articulo= "
read Precio_basico
if(Precio_basico>=0&&Precio_basico<=20)
{
Impuesto=0.0
}
else
{
if(Precio_basico>20&&Precio_basico<=40)
{
Impuesto=(Precio_basico)*(0.30)
}
else
{
if(Precio_basico<500)
{
Impuesto=(Precio_basico)*(0.40)
}
else
{
Impuesto=(Precio_basico)*(0.50)
}}}
Precio_total=Precio_basico+Impuesto
print"Precio total= ",Precio_total
pint"desea continuar S/N=?"
read sigue
fin
















problema 5

#include <iostream.h>
#include <conio.h>
#include <math.h>
int main ()
{
float a,b,c;
float x1,x2,R;
char sigue='s';
while(sigue=='s'||sigue=='S')
{
cout<<"ax2+bx+c=0"<<endl;
cout<<"introducir el valor de a= ";
cin>>a;
cout<<"introducir el valor de b= ";
cin>>b;
cout<<"introducir el valor de c= ";
cin>>c;
cout<<"\n"<<endl;
R=b*b-4*a*c;
if(R>0)
{
x1=(-b+sqrt(R))/(2*a);
x2=(-b-sqrt(R))/(2*a);
cout<<"El valor de x1 es= "<<x1<<endl;
cout<<""<<endl;
cout<<"El valor de x2 es= "<<x2<<endl;
}
else
{
cout<<"la raiz es imaginaria"<<endl;
}
cout<<"desea continuar S/N=?";
cin>>sigue;
clrscr();
}
getch();
}


pseudocodigo

inicio
a,b,c real
 x1,x2,R real
char sigue='s';
while(sigue=='s'||sigue=='S')
{
print"ax2+bx+c=0"
print"introducir el valor de a= "
read a
print"introducir el valor de b= "
read b
print"introducir el valor de c= "
rad c
print"\n"
R=b*b-4*a*c;
if(R>0)
{
x1=(-b+sqrt(R))/(2*a)
x2=(-b-sqrt(R))/(2*a)
print"El valor de x1 es= ",x1
print""<<endl;
print"El valor de x2 es= ",x2
}
else
{
print"la raiz es imaginaria"
}
print"desea continuar S/N=?"
read sigue
fin







problema 3 practica 6
codigo en c++

#include <iostream.h>
#include <conio.h>

int main()
{
int n=0, si;
float t=0;
while (si==n)
{
cout<<"Numero de sonidos del grillo por minuto=";
cin>>n;
if(n>0)
{
t=n/4+40 ;
}
else
{
t=0;
}

cout<<"la Temperatura es="<<t<<endl;
cout<<" para continuar 1"<<si
<<endl;
}
getch();
}


problema 4



No hay comentarios:

Publicar un comentario