Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int calcMark(int p)
- {
- // ist p im erlaubten Intervall?
- if ( p < 0 || p > 100 )
- {
- // nein, Abbruch
- return -1;
- }
- else if (p < 45) // weiter geht's wie gehabt
- {
- return 5;
- }
- else if ( p >= 45 && p < 60 )
- {
- return 4;
- }
- else if ( p >= 60 && p < 75)
- {
- return 3;
- }
- else if ( p >= 75 && p < 90)
- {
- return 2;
- }
- else // jetzt bleibt nur noch der Fall p > 90 übrig
- {
- return 1;
- }
- }
- int main()
- {
- int punktzahl;
- int note;
- cout << "Notenberechnung" << endl << endl;
- cout << "Geben Sie die erreichte Punktzahl ein: ";
- cin >> punktzahl;
- note = calcMark(punktzahl);
- cout << "Mit der Punktzahl von " << punktzahl << " Punkten haben Sie eine Note von " << note << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement