1
The problem is that in all three cases, cout
repeats endlessly.
#include<iostream>
using namespace std;
#include<locale.h>
int main(){
setlocale(LC_ALL, "Portuguese");
bool a;
int consumo;
cout << "Digite 1 -> até 100kw" << endl;
cout << "Digite 2 -> de 101kw até 200kw" << endl;
cout << "Digite 3 -> maior que 200kw" << endl;
cin >> consumo;
while(true){
switch(consumo){
case 1:
cout << "Parabéns, você é econômico." << endl;
break;
case 2:
cout << "Cuidado, você está gastando muito." << endl;
break;
case 3:
cout << "Que isso vei?" << endl;
break;
default:
cout << "Valor inválido, tente novamente." << endl;
cout << "Digite 1 -> até 100kw" << endl;
cout << "Digite 2 -> de 101kw até 200kw" << endl;
cout << "Digite 3 -> maior que 200kw" << endl;
cin >> consumo;
continue;
}
}
return 0;
}
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero