Advertisement
Guest User

Notenberechnung-Ingo

a guest
Nov 23rd, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int calcMark(int p)
  6. {
  7.     // ist p im erlaubten Intervall?
  8.     if ( p < 0 || p > 100 )
  9.     {
  10.         // nein, Abbruch
  11.         return -1;
  12.     }
  13.     else if (p < 45)    // weiter geht's wie gehabt
  14.     {
  15.         return 5;      
  16.     }
  17.     else if ( p >= 45 && p < 60  )
  18.     {
  19.         return 4;
  20.     }
  21.     else if ( p >= 60 && p < 75)
  22.     {
  23.         return 3;
  24.     }
  25.     else if ( p >= 75 && p < 90)
  26.     {
  27.         return 2;
  28.     }
  29.     else    // jetzt bleibt nur noch der Fall p > 90 übrig
  30.     {
  31.         return 1;
  32.     }
  33. }
  34.  
  35. int main()
  36. {
  37.     int punktzahl;
  38.     int note;
  39.  
  40.     cout << "Notenberechnung" << endl << endl;
  41.  
  42.     cout << "Geben Sie die erreichte Punktzahl ein: ";
  43.     cin >> punktzahl;  
  44.  
  45.     note = calcMark(punktzahl);
  46.  
  47.     cout << "Mit der Punktzahl von " << punktzahl << " Punkten  haben Sie eine Note von " << note << endl;
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement