Guest User

Untitled

a guest
Aug 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int i, q;
  9.  
  10. float valor;
  11.  
  12. cin >> i >> q;
  13.  
  14. switch (i) {
  15. case 1:
  16. valor = 4.00*q;
  17. case 2:
  18. valor = 4.50*q;
  19. case 3:
  20. valor = 5.00*q;
  21. case 4:
  22. valor = 2.00*q;
  23. case 5:
  24. valor = 1.50*q;
  25. }
  26.  
  27. cout << "Total: R$" << valor;
  28. }
  29.  
  30. #include <iostream>
  31. using namespace std;
  32.  
  33. int main() {
  34. int item, qtde;
  35. float valor;
  36. cin >> item >> qtde;
  37. switch (item) {
  38. case 1:
  39. valor = 4.00;
  40. break;
  41. case 2:
  42. valor = 4.50;
  43. break;
  44. case 3:
  45. valor = 5.00;
  46. break;
  47. case 4:
  48. valor = 2.00;
  49. break;
  50. case 5:
  51. valor = 1.50;
  52. break;
  53. }
  54. cout << "Total: R$" << valor * qtde;
  55. }
  56.  
  57. #include <iostream>
  58. #include <array>
  59. using namespace std;
  60.  
  61. int main() {
  62. int item, qtde;
  63. cin >> item >> qtde;
  64. array<float, 5> valores = { 4.00, 4.50, 5.00, 2.00, 1.50 };
  65. cout << "Total: R$" << valores[item - 1] * qtde;
  66. }
Add Comment
Please, Sign In to add comment