001    package de.hska.java.aufgaben.kontrollstrukturen;
002    
003    /**
004     * Mit Notenvergabe können Klausurpunkte in Noten umgerechnet werden.
005     * 
006     * <p>
007     *   <a href="http://www.home.hs-karlsruhe.de/~pach0003/informatik_1/aufgaben/kontrollanweisungen.html#notenberechnung">Zurück zum Aufgabentext</a>
008     * </p>
009     * 
010     * 
011     * @author Christian Pape
012     */
013    public class Notenvergabe {
014    
015        /**
016         * Gibt für alle Punkte von 0 bis 120 (in Schritten von 0.5)
017         * die zugehörige Note auf dem Bildschirm aus.
018         */
019        public static void main(String[] args) {
020            for (double punkte = 0.0; punkte < 120.0; punkte += 0.5) {
021                System.out.println(punkte + " -> " + Notenvergabe.getNote(punkte));
022            }
023        }
024    
025        /**
026         * Gibt für die gegebene Anzahl Punkte (von 0 bis 120) die
027         * Klausurnote zurück.
028         */
029        public static double getNote(double punkte) {
030            double note = 5.0;
031           
032            if (50.0 <= punkte && punkte < 59.9) {
033                note = 4.7;
034            } else if (60.0 <= punkte && punkte < 64.9) {
035                note = 4.0;
036            } else if (65.0 <= punkte && punkte < 69.9) {
037                note = 3.7;
038            } else if (70.0 <= punkte && punkte < 75.9) {
039                note = 3.3;
040            } else if (75.0 <= punkte && punkte < 79.9) {
041                note = 3.0;
042            } else if (80 <= punkte && punkte < 84.9) {
043                note = 2.7;
044            } else if (85 <= punkte && punkte < 89.9) {
045                note = 2.3;
046            } else if (90 <= punkte && punkte < 94.9) {
047                note = 2.0;
048            } else if (95 <= punkte && punkte < 99.9) {
049                note = 1.7;
050            } else if (100 <= punkte && punkte < 104.9) {
051                note = 1.3;
052            } else if (105 <= punkte && punkte < 120.4) {
053                note = 1.0;
054            }
055            
056            
057            return note;
058        }
059    }