Ir para conteúdo
Fórum Script Brasil

Matheus Cristian

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Matheus Cristian

Matheus Cristian's Achievements

0

Reputação

  1. Oi, estou fazendo uma calculadora e quando alguém quer multiplicar dois números, se ela digitar X quero q o X vire x para o programa entender. tentei fazer assim: #include <iostream> #include <ctype.h> using namespace std; string toLower (string string) { int i; for(i = 0; i < 3; i++) string = tolower(string[i]); } float operations (string operation, float num1, float num2) { if (operation == "+") { cout << num1 + num2; } else if (operation == "-") { cout << num1 - num2; } else if (operation == "/") { cout << num1 / num2, "\n"; } else if (operation == "x") { cout << num1 * num2; } else { cout << "Enter a valid operation!!!"; system("pause"); exit(0); } } int main (){ cout << "Enter a number: "; float n1 = 0; if (!(cin >> n1)) { cout << "Enter a valid value!!!\n"; system("pause"); exit(0); } cout << "Enter another number: "; float n2 = 0; if (!(cin >> n2)) { cout << "Enter a valid value!!!\n"; system("pause"); exit(0); } string operation_type = "None"; cout << "[+ = Addition, - = Subtraction, X = Multiplication, / = Division]\n"; cout << "Enter operation type: "; cin >> operation_type; toLower(operation_type); operations(operation_type, n1, n2); }
×
×
  • Criar Novo...