im trying to put a simple menu at the end of the program that gives the user the option to repeat the program, it a proyect for my class XDXDXDXD so it can only be done using FOR, WHILE, DO-WHILE, SWITCH, <CMATH> AND other simple functions, this code is used to calculate how many dollars of 100, 50, 20, 10, 5, 1 i can use until i get to the amount specified by the user. appreciated the help SORRY IS IN SPANISH THE MENU MENU IS IN ENGLISH DO XD
#include<iostream>
#include<cmath>
usingnamespace std;
int main()
{
double cant;
int A, B, C, D, E, F, totalA, totalB, totalC, totalD, totalE, totalF;
do
{
cout<<"Ingrese la cantidad que desea pagar:\n";
cin>>cant;
}
while(cant<0);
{
if(cant>100)
{
A=cant/100;
totalA=A*100-cant;
B=totalA/50;
totalB=B*50-totalA;
C=totalB/20;
totalC=C*20-totalB;
D=totalC/10;
totalD=D*10-totalC;
E=totalD/5;
totalE=E*5-totalD;
F=totalE/1;
totalF=F*1-totalE;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 100 es de :"<<A<<"\n";
cout<<"En billetes de 50 es de :"<<B<<"\n";
cout<<"En billetes de 20 es de :"<<C<<"\n";
cout<<"En billetes de 10 es de :"<<D<<"\n";
cout<<"En billetes de 5 es de :"<<E<<"\n";
cout<<"En billetes de 1 es de :"<<F<<"\n";
}
elseif(cant<=99 && cant>=50)
{
A=cant/50;
totalA=A*50-cant;
B=totalA/20;
totalB=B*20-totalA;
C=totalB/10;
totalC=C*10-totalB;
D=totalC/5;
totalD=D*5-totalC;
E=totalD/1;
totalE=E*1-totalD;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 50 es de :"<<A<<"\n";
cout<<"En billetes de 20 es de :"<<B<<"\n";
cout<<"En billetes de 10 es de :"<<C<<"\n";
cout<<"En billetes de 5 es de :"<<D<<"\n";
cout<<"En billetes de 1 es de :"<<E<<"\n";
}
elseif(cant<=49 && cant>=20)
{
A=cant/20;
totalA=A*20-cant;
B=totalA/10;
totalB=B*10-totalA;
C=totalB/5;
totalC=C*5-totalB;
D=totalC/1;
totalD=D*1-totalC;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 20 es de :"<<A<<"\n";
cout<<"En billetes de 10 es de :"<<B<<"\n";
cout<<"En billetes de 5 es de :"<<C<<"\n";
cout<<"En billetes de 1 es de :"<<D<<"\n";
}
elseif(cant<=19 && cant>=10)
{
A=cant/10;
totalA=A*10-cant;
B=totalA/5;
totalB=B*5-totalA;
C=totalB/1;
totalC=C*1-totalB;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 10 es de :"<<A<<"\n";
cout<<"En billetes de 5 es de :"<<B<<"\n";
cout<<"En billetes de 1 es de :"<<C<<"\n";
}
elseif(cant<=9 && cant>=1)
{
A=cant/5;
totalA=A*5-cant;
B=totalA/1;
totalB=B*1-totalA;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 5 es de :"<<A<<"\n";
cout<<"En billetes de 1 es de :"<<B<<"\n";
}
else
cout<<"nose\n";
}
system("pause");
return 0;
}
#include<iostream>
#include<cmath>
usingnamespace std;
int main()
{
double cant;
char eleccion = 'n';
int A, B, C, D, E, F, totalA, totalB, totalC, totalD, totalE, totalF;
do
{
do
{
cout<<"Ingrese la cantidad que desea pagar:\n";
cin>>cant;
}
while(cant<0);
if(cant>100)
{
A=cant/100;
totalA=A*100-cant;
B=totalA/50;
totalB=B*50-totalA;
C=totalB/20;
totalC=C*20-totalB;
D=totalC/10;
totalD=D*10-totalC;
E=totalD/5;
totalE=E*5-totalD;
F=totalE/1;
totalF=F*1-totalE;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 100 es de :"<<A<<"\n";
cout<<"En billetes de 50 es de :"<<B<<"\n";
cout<<"En billetes de 20 es de :"<<C<<"\n";
cout<<"En billetes de 10 es de :"<<D<<"\n";
cout<<"En billetes de 5 es de :"<<E<<"\n";
cout<<"En billetes de 1 es de :"<<F<<"\n";
}
elseif(cant<=99 && cant>=50)
{
A=cant/50;
totalA=A*50-cant;
B=totalA/20;
totalB=B*20-totalA;
C=totalB/10;
totalC=C*10-totalB;
D=totalC/5;
totalD=D*5-totalC;
E=totalD/1;
totalE=E*1-totalD;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 50 es de :"<<A<<"\n";
cout<<"En billetes de 20 es de :"<<B<<"\n";
cout<<"En billetes de 10 es de :"<<C<<"\n";
cout<<"En billetes de 5 es de :"<<D<<"\n";
cout<<"En billetes de 1 es de :"<<E<<"\n";
}
elseif(cant<=49 && cant>=20)
{
A=cant/20;
totalA=A*20-cant;
B=totalA/10;
totalB=B*10-totalA;
C=totalB/5;
totalC=C*5-totalB;
D=totalC/1;
totalD=D*1-totalC;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 20 es de :"<<A<<"\n";
cout<<"En billetes de 10 es de :"<<B<<"\n";
cout<<"En billetes de 5 es de :"<<C<<"\n";
cout<<"En billetes de 1 es de :"<<D<<"\n";
}
elseif(cant<=19 && cant>=10)
{
A=cant/10;
totalA=A*10-cant;
B=totalA/5;
totalB=B*5-totalA;
C=totalB/1;
totalC=C*1-totalB;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 10 es de :"<<A<<"\n";
cout<<"En billetes de 5 es de :"<<B<<"\n";
cout<<"En billetes de 1 es de :"<<C<<"\n";
}
elseif(cant<=9 && cant>=1)
{
A=cant/5;
totalA=A*5-cant;
B=totalA/1;
totalB=B*1-totalA;
cout<<"Su cantidad a pagar:\n";
cout<<"En billetes de 5 es de :"<<A<<"\n";
cout<<"En billetes de 1 es de :"<<B<<"\n";
}
else
cout<<"nose\n";
cout<<endl<<"Te gustaria repetir? Pulse 'y' para seguir mas de prensa de cualquier otro alfabeto para salir: ";
cin>>eleccion;
}
while(eleccion == 'y' || eleccion == 'Y');
system("pause");
return 0;
}