class VehicleRange { public static void main (String... args) { double fuellstand; double verbrauch; // Kommandozeile nach Parametern abfragen try { fuellstand = Double.parseDouble(args[0]); verbrauch = Double.parseDouble(args[1]); } catch (NumberFormatException e) { System.out.println ("Keine Argumente übergeben, keine Berechnung möglich!"); } // Welche Methode? (d.h.welcher Verbrauch?) if (verbrauch == 0) { System.out.println("Reichweite: " + Stadt(fuellstand) + "km"); } if (verbrauch == 1) { System.out.println("Reichweite: " + Land(fuellstand) + "km"); } if (verbrauch == 2) { System.out.println("Reichweite: " + Autobahn(fuellstand) + "km"); } if (verbrauch > 2) { System.out.println("Reichweite: " + BeideParam(fuellstand, verbrauch) + "km"); } } // genaue Reichweitenberechnung mit beiden Parametern static double BeideParam (double fuellstand, double verbrauch) { double a = (fuellstand / verbrauch) *100; return a; } // Reichweite in Stadt static double Stadt (double fuellstand) { double a = fuellstand * 10; return a; } // Reichweite auf Landstraße static double Land (double fuellstand) { double a = (fuellstand / 8) * 100; return a; } // Reichweite auf Autobahn static double Autobahn (double fuellstand) { double a = (fuellstand / 6.5) * 100; return a; } } wildwillyjohn@wildwillyjohn-lap:~/Programmieren Java$ javac vehicleRange.java vehicleRange.java:17: variable verbrauch might not have been initialized if (verbrauch == 0) ^ vehicleRange.java:19: variable fuellstand might not have been initialized System.out.println("Reichweite: " + Stadt(fuellstand) + "km"); ^ vehicleRange.java:23: variable fuellstand might not have been initialized System.out.println("Reichweite: " + Land(fuellstand) + "km"); ^ vehicleRange.java:27: variable fuellstand might not have been initialized System.out.println("Reichweite: " + Autobahn(fuellstand) + "km"); ^ vehicleRange.java:31: variable fuellstand might not have been initialized System.out.println("Reichweite: " + BeideParam(fuellstand, verbrauch) + "km"); ^ 5 errors