dollars = dollars + 1000 ;
Hier ist das vervollständigte Programm:
class MillionDollarJahre
{
public static void main( String[] args )
{
double dollars = 1000.00 ;
int jahre = 0;
while ( dollars < 1000000.00 )
{
// Zinsen für ein weiteres Jahr addieren
dollars = dollars + dollars*0.05 ;
// fügen Sie die jährliche Einzahlung hinzu
dollars = dollars + 1000 ;
jahre = jahre + 1 ;
}
System.out.println("Es braucht " + jahre + " Jahre um das Ziel zu erreichen.");
}
}
Und hier ist der Output:
C:\Notes\chap19>java MillionDollarYears Es braucht 80 Jahre um das Ziel zu erreichen.