Effektivzinsrechner - Was mache Ich faksch ?

  • Was mache ich falsch ???

    [autoit]

    #include <GUIConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    $Leihdauer = 0
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Effektivzinsrechner | Lizenz: 4lph4", 346, 262, 284, 213)
    $Label1 = GUICtrlCreateLabel("Leihbetrag", 24, 24, 117, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Label2 = GUICtrlCreateLabel("Leihdauer", 24, 64, 109, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Label3 = GUICtrlCreateLabel("Prozentsatz", 24, 104, 127, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Input1 = GUICtrlCreateInput("", 184, 32, 129, 21)
    $Input2 = GUICtrlCreateInput("", 184, 64, 129, 21)
    $Input3 = GUICtrlCreateInput("", 184, 104, 129, 21)
    $Button1 = GUICtrlCreateButton("Endsumme berechnen", 24, 136, 289, 33, 0)
    $Group1 = GUICtrlCreateGroup("", 8, 8, 329, 241)
    $Label4 = GUICtrlCreateLabel("Endsumme", 112, 176, 120, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Input4 = GUICtrlCreateInput("", 56, 208, 225, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUICtrlSetData($Leihdauer,0)
    $read = GUICtrlRead($Input1)
    GUICtrlSetData($Input4,$read)
    While 2
    $readLeihdauer = GUICtrlRead($Leihdauer)
    $readInput2 = GUICtrlRead($Input2)
    $read2 = GUICtrlRead($Input4)
    $read3 = GUICtrlRead($Input3)
    GUICtrlSetData($Input4,$read2+($read2*$read3/100))
    $Leihdauer = $Leihdauer + 1
    If $readLeihdauer = $readInput2 Then ExitLoop
    WEnd
    GUICtrlSetData($Input1,"")
    GUICtrlSetData($Input2,"")
    GUICtrlSetData($Input3,"")
    EndSwitch
    WEnd

    [/autoit]
  • So sollte es funzen:

    [autoit]


    #include <GUIConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    $Leihdauer = 0
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Effektivzinsrechner | Lizenz: 4lph4", 346, 262, 284, 213)
    $Label1 = GUICtrlCreateLabel("Leihbetrag", 24, 24, 117, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Label2 = GUICtrlCreateLabel("Leihdauer", 24, 64, 109, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Label3 = GUICtrlCreateLabel("Prozentsatz", 24, 104, 127, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Input1 = GUICtrlCreateInput("10000", 184, 32, 129, 21)
    $Input2 = GUICtrlCreateInput("5", 184, 64, 129, 21)
    $Input3 = GUICtrlCreateInput("7.5", 184, 104, 129, 21)
    $Button1 = GUICtrlCreateButton("Endsumme berechnen", 24, 136, 289, 33, 0)
    $Group1 = GUICtrlCreateGroup("", 8, 8, 329, 241)
    $Label4 = GUICtrlCreateLabel("Endsumme", 112, 176, 120, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Input4 = GUICtrlCreateInput("", 56, 208, 225, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    ;~ GUICtrlSetData($Leihdauer,0)
    $read = GUICtrlRead($Input1)
    ;~ GUICtrlSetData($Input4,$read)
    ;~ While 2
    ;~ $readLeihdauer = GUICtrlRead($Leihdauer)
    $readInput2 = GUICtrlRead($Input2)
    $read2 = GUICtrlRead($Input4)
    $read3 = GUICtrlRead($Input3)
    $zins = $read * (1 + ($read3 / 100))^$readInput2
    GUICtrlSetData($Input4,Round($zins,2) & " €")
    ;~ $Leihdauer = $Leihdauer + 1
    ;~ If $readLeihdauer = $readInput2 Then ExitLoop
    ;~ WEnd
    ;~ GUICtrlSetData($Input1,"")
    ;~ GUICtrlSetData($Input2,"")
    ;~ GUICtrlSetData($Input3,"")
    EndSwitch
    WEnd

    [/autoit]

    Zins Formel:
    K0 = Anfangskapital
    Zn = Endkapital
    P = Prozent
    T = Jahre

    ==> Zn = K0 * (1 + (P / 100))^T

    Klasse 7 Mathematik 8)

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    Einmal editiert, zuletzt von UEZ (16. Oktober 2009 um 10:57)

  • Hallo mongobongo,

    hier noch die Lösung mit Schleife (wenn man die Zinseszinsformel nicht kennt):

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Effektivzinsrechner | Lizenz: 4lph4", 346, 262, 284, 213)
    $Label1 = GUICtrlCreateLabel("Leihbetrag", 24, 24, 117, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Label2 = GUICtrlCreateLabel("Leihdauer", 24, 64, 109, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $Label3 = GUICtrlCreateLabel("Prozentsatz", 24, 104, 127, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $hKapital = GUICtrlCreateInput("", 184, 32, 129, 21)
    $hZeit = GUICtrlCreateInput("", 184, 64, 129, 21)
    $hZinssatz = GUICtrlCreateInput("", 184, 104, 129, 21)
    $Button1 = GUICtrlCreateButton("Endsumme berechnen", 24, 136, 289, 33, 0)
    $Group1 = GUICtrlCreateGroup("", 8, 8, 329, 241)
    $Label4 = GUICtrlCreateLabel("Endsumme", 112, 176, 120, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    $hErgebnis = GUICtrlCreateInput("", 56, 208, 225, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    ;GUICtrlSetData($i, 0)
    $i = 0
    $Kapital = GUICtrlRead($hKapital)
    $Zinssatz = GUICtrlRead($hZinssatz)
    $Zeit = GUICtrlRead($hZeit)
    #cs
    While $i < $Zeit ;Lösung mit While Wend
    $Zins = $Kapital * $Zinssatz / 100
    ConsoleWrite(" nach " & $i & "Jahren: " & $Kapital & " " & $Zins & @CRLF)
    $Kapital = $Kapital + $Zins
    $i = $i + 1
    WEnd
    #ce
    For $i = 1 To $Zeit ;bessere Lösung mit For next
    $Zins = $Kapital * $Zinssatz / 100
    ConsoleWrite(" nach " & $i & "Jahren: " & $Kapital & " + Zins für Jahr " & $i & ": " & $Zins & @CRLF)
    $Kapital = $Kapital + $Zins
    Next
    GUICtrlSetData($hErgebnis, round($Kapital,2))
    #cs
    GUICtrlSetData($hKapital,"")
    GUICtrlSetData($Zeit,"")
    GUICtrlSetData($hZinssatz,"")
    #ce
    EndSwitch
    WEnd

    [/autoit]

    gleiches Ergebnis, nur mehr Rechenaufwand

    mfg (Auto)Bert