Advertisement
Gilgamesh858

ggwpIoVado.cpp

Jun 16th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdio>
  6. using namespace std;
  7.  
  8. #define A 0
  9. #define A+ 1
  10. #define A- 2
  11. #define B 3
  12. #define B+ 4
  13. #define B- 5
  14. #define C 6
  15. #define C+ 7
  16. #define C- 8
  17. #define D 9
  18. #define D+ 10
  19. #define D- 11
  20. #define F 12
  21.  
  22. int main ()
  23. {
  24.     string grado;
  25.     float valore;
  26.     cout << "Inserisci il grado da A a F : " ;
  27.     cin >> grado;
  28.  
  29.     switch(grado.at(0)){
  30.         case 'A' :
  31.                 if(grado.length()<2){
  32.                         valore = 4;
  33.                         break;
  34.                 }
  35.                 if(grado.at(1)=='+'){
  36.                     valore = 4.3;
  37.                     break;
  38.                 }
  39.                 valore = 3.7;
  40.                 break;
  41.         case 'B' :
  42.                 if(grado.length()<2){
  43.                         valore = 3;
  44.                         break;
  45.                 }
  46.                 if(grado.at(1)=='+'){
  47.                     valore = 3.3;
  48.                     break;
  49.                 }
  50.                 valore = 2.7;
  51.                 break;
  52.  
  53.                 valore = 3;
  54.                 break;
  55.         case 'C' :
  56.                 if(grado.length()<2){
  57.                         valore = 2;
  58.                         break;
  59.                 }
  60.                 if(grado.at(1)=='+'){
  61.                     valore = 2.3;
  62.                     break;
  63.                 }
  64.                 valore = 1.7;
  65.                 break;
  66.         case 'D' :
  67.                 if(grado.length()<2){
  68.                         valore = 1;
  69.                         break;
  70.                 }
  71.                 if(grado.at(1)=='+'){
  72.                     valore = 1.3;
  73.                     break;
  74.                 }
  75.                 valore = 0.7;
  76.                 break;
  77.         case 'F' : valore = 0;
  78.             break;
  79.         default : cout << "Errore di inserimento " << endl;
  80.             break;
  81.     }
  82.     cout << valore;
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement