elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / como delimitar un rango en: 27 Febrero 2022, 17:28 pm
buenos dias tengo que crear este algoritmo ya lo tengo montado pero necesito que cuando se solicite la clave solo se puedan escribir las opciones que deja el ejercicio esa que si me escribe una clave distinta a ( 12,15,18,19,23,25,19) no deje continuar y vuelva a pedir la clave que puedo hacer porfavor
Código
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6.  
  7. int main(int argc, char** argv) {
  8. float Clave = 0;
  9. float Tiempo = 0;
  10. float Precio = 0;
  11.  
  12. cout << "Ingrese la clave de la zona: ";
  13. cin >> Clave;
  14. cout << "Ingrese el tiempo hablado: ";
  15. cin >> Tiempo;
  16.  
  17. if (Clave == 12) {
  18. Precio = 4 * Tiempo;
  19. }else if (Clave == 15) {
  20. Precio = 3.2 * Tiempo;
  21. }
  22. else if (Clave == 18) {
  23. Precio = 5.5 * Tiempo;
  24. }
  25. else if (Clave == 19) {
  26. Precio = 4.8 * Tiempo;
  27. }
  28. else if (Clave == 23) {
  29. Precio = 7 * Tiempo;
  30. }
  31. else if (Clave == 25) {
  32. Precio = 7 * Tiempo;
  33. }
  34. else if (Clave == 29) {
  35. Precio = 4 * Tiempo;
  36. }
  37.  
  38. cout << "\nValor a pagar: " << Precio << " $";
  39.  
  40. cout << endl << endl;
  41. system("pause");
  42. return 0;
  43. }

MOD: Etiquetas de Código GeSHi
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines