I'm trying to solve the problem of Uri 1038 using switch
, apparently the values are mixing, Item 3 for example multiplying by 2 (5 x 2) returns the value 3. What am I doing wrong here ?
#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;
}