Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int i, q;
- float valor;
- cin >> i >> q;
- switch (i) {
- case 1:
- valor = 4.00*q;
- case 2:
- valor = 4.50*q;
- case 3:
- valor = 5.00*q;
- case 4:
- valor = 2.00*q;
- case 5:
- valor = 1.50*q;
- }
- cout << "Total: R$" << valor;
- }
- #include <iostream>
- using namespace std;
- int main() {
- int item, qtde;
- float valor;
- cin >> item >> qtde;
- switch (item) {
- case 1:
- valor = 4.00;
- break;
- case 2:
- valor = 4.50;
- break;
- case 3:
- valor = 5.00;
- break;
- case 4:
- valor = 2.00;
- break;
- case 5:
- valor = 1.50;
- break;
- }
- cout << "Total: R$" << valor * qtde;
- }
- #include <iostream>
- #include <array>
- using namespace std;
- int main() {
- int item, qtde;
- cin >> item >> qtde;
- array<float, 5> valores = { 4.00, 4.50, 5.00, 2.00, 1.50 };
- cout << "Total: R$" << valores[item - 1] * qtde;
- }
Add Comment
Please, Sign In to add comment