First commit
This commit is contained in:
38
IUT/Info1/TD/Exercices/7.2_selon/main.cpp
Normal file
38
IUT/Info1/TD/Exercices/7.2_selon/main.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "calc.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float a, b;
|
||||
float result;
|
||||
char operation;
|
||||
|
||||
cout << "Saisir a" << endl;
|
||||
cin >> a;
|
||||
cout << "Saisir l'opération" << endl;
|
||||
cin >> operation;
|
||||
cout << "Saisir b" << endl;
|
||||
cin >> b;
|
||||
|
||||
|
||||
switch (operation) {
|
||||
case '+' :
|
||||
result = add(a, b);
|
||||
break;
|
||||
case '-':
|
||||
result = sub(a, b);
|
||||
break;
|
||||
case '*':
|
||||
result = mul(a, b);
|
||||
break;
|
||||
case '/':
|
||||
result = div(a, b);
|
||||
break;
|
||||
default:
|
||||
throw runtime_error("You did not provide a valid operation");
|
||||
}
|
||||
|
||||
cout << "Le résultat est " << result << endl;
|
||||
}
|
||||
Reference in New Issue
Block a user