1   /** 
2    * 183.592 Programmierpraxis TU Wien WS2014/15 H.Moritsch
3    * Ausgabe der Werte der Funktion y(x) = x*x-0.5*x+2 im Intervall von a bis b 
4    * mit einer bestimmten Schrittweite dx
5    */
6   public class Funktion {
7       public static void main(String[] args) {
8   
9           double a  = -5.0;
10          double b  = 5.0;
11          double dx = 1.0;
12  
13          double x;           // Argument der Funktion
14          double y;           // Funktionswert
15  
16          // Vorbereitung der Schleife 
17  
18          x = a;              // Beginn des Intervalls
19  
20          // *solange* x innerhalb des Intervalls liegt:
21  
22          while (x <= b) {
23  
24              y = x * x - 0.5 * x + 2.0;  // Berechnung des Funktionswertes
25  
26              System.out.println(y);  
27  
28              x = x + dx;                 // x wird um die Schrittweite erhöht
29          }
30  
31      }
32  }
33