Lösung Übung 7: Gesamtwiderstand berechnen
public class Widerstand {
public static void main( String[] args ) {
double sum = 0;
for( int i = 0; i < args.length; i++ ) {
try {
sum += 1/Double.parseDouble( args[i] );
}
catch( NumberFormatException e ) {
System.out.println( e.toString() );
System.exit(1);
}
}
// Ausgabe
System.out.println("Gesamtwiderstand: " + ( 1/sum ) );
}
}
[Index]