I was doing a program in C ++, using the switch type function
I asked for the price of an item, I read it, then I asked for the discount option that depends on the price, but this discount option is entered manually
I enclose my code to understand what I mean:
#include <iostream>
using namespace std;
int main()
int precio, tot_pagar;
char opcion;
cout<< "Ingrese el precio ";
cin>> precio;
cout<< endl;
cout<< "Ingrese la opción de descuento ";
cin>> opcion;
switch (opcion)
{
case 'A': tot_pagar = precio-precio*0.05;
cout<< "El total a pagar es "; tot_pagar;
break;
case 'B': tot_pagar = precio-precio*0.10;
cout<< "El total a pagar es "; tot_pagar;
break;
case 'C': tot_pagar = precio-precio*0.15;
cout<< "El total a pagar es "; tot_pagar;
break;
default: cout<< "Su artículo no tiene descuento";
}
return 0;
When the program starts, enter the price, the option, but then do not print the corresponding operation, depending on the case.