Created
December 5, 2017 22:13
-
-
Save Jan200101/f5cab7c6f995b8610c0eca710c59bf3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <iomanip> | |
| #include <stdlib.h> | |
| #include <conio.h> | |
| using namespace std; | |
| void rente() | |
| { | |
| int JahrZahler = 0, MonatZahler = 0, Zinsen = 0; | |
| float KontoStand, RentenGeld, AuszahlungsMenge = -1; | |
| cout << "Wie viel Geld ist auf dem Konto?\n"; | |
| cin >> KontoStand; | |
| // defines how often rent is paid in a year | |
| while (AuszahlungsMenge <= 0) | |
| { | |
| cout << "Wie oft soll im Jahr Geld ausgezahlt werden (in Monate)\n"; | |
| cin >> AuszahlungsMenge; | |
| if (0 >= AuszahlungsMenge && AuszahlungsMenge < 13) | |
| { | |
| AuszahlungsMenge = 0; | |
| cout << AuszahlungsMenge << " ist nicht in der Reichweite 0 bis 12\n"; | |
| } | |
| } | |
| cout << "Wie viel Renten Geld soll ausgegeben werden\n"; | |
| cin >> RentenGeld; | |
| cout << "Was ist der Zinssatz?\n"; | |
| cin >> Zinsen; | |
| // Counts months and years | |
| // multiplies the interests and returns the values | |
| while ((KontoStand - RentenGeld) >= 0) | |
| { | |
| if (MonatZahler >= 12) | |
| { | |
| // 12 Monate sind 1 Jahr | |
| JahrZahler += 1; | |
| MonatZahler -= 12; | |
| // multiply the balance by the interests and add it to the balance | |
| KontoStand = KontoStand + KontoStand * Zinsen; | |
| } | |
| // returns the balance with a month and year counter | |
| if ( JahrZahler <= 0) { | |
| cout << MonatZahler << " Monate "<< KontoStand << endl; | |
| } else { | |
| cout << JahrZahler << " Jahre " << MonatZahler << " Monate "<< KontoStand << endl; | |
| } | |
| if (MonatZahler < AuszahlungsMenge) | |
| { | |
| KontoStand -= RentenGeld; | |
| } | |
| MonatZahler++; | |
| } | |
| // Returns the time Rent could be paid | |
| if ( JahrZahler <= 0) { | |
| cout << "Es konnte für " << MonatZahler << " Monate Rente ausgezahlt werden" << endl; | |
| } else { | |
| cout << "Es konnte für " << JahrZahler << " Jahre " << MonatZahler << " Monate Rente ausgezahlt werden" << endl; | |
| } | |
| } | |
| void wohnung() | |
| { | |
| float Zins,einzahlung,auszahlung; | |
| int ZeitJahr, JahrEingabe; | |
| cout<<"Geben sie ihre Einzahlung ein"<<endl; | |
| cin>>einzahlung; | |
| cout<<"Geben sie ihren Zinssatz ein"<<endl; | |
| cin>> Zins; | |
| cout<<"Geben sie die Zeit in Jahren ein"<<endl; | |
| cin>> JahrEingabe; | |
| for(ZeitJahr=1;ZeitJahr<=JahrEingabe ; ZeitJahr++) | |
| { | |
| auszahlung=einzahlung+einzahlung*Zins; | |
| auszahlung=auszahlung*ZeitJahr; | |
| cout<<auszahlung<<endl; | |
| } | |
| } | |
| void fuhrerschein() | |
| { | |
| float einzahlung; | |
| float kontostand,sparziel,zinssatz; | |
| cout<<"Geben sie ihr zinssatz ein"<<endl; | |
| cin>>zinssatz; | |
| cout<<"Geben sie ihr Sparziel ein"<<endl; | |
| cin>>sparziel; | |
| cout<<"Geben sie ihre einzahlung ein"<<endl; | |
| cin>>einzahlung; | |
| do | |
| { | |
| einzahlung=einzahlung*12; | |
| einzahlung=einzahlung*zinssatz; | |
| kontostand=kontostand+einzahlung; | |
| cout<<"Ihr Kontostand betraegt "<<kontostand<<" Euro"<<endl; | |
| } | |
| while(kontostand<=sparziel); | |
| } | |
| int main() | |
| { | |
| // set to true so the main loop works | |
| bool loop = true; | |
| int menuinput; | |
| // Main program loop | |
| // Loop until option 0 gets picked | |
| // which sets loop to false | |
| while (loop) { | |
| // runs the Windows command cls, CLearScreen. | |
| // does not work on unix systems without some editing | |
| system("cls"); | |
| cout << "Wahle das Program aus\n" << "1) Rente\n" << "2) Wohnung\n" << "3) Fuehrerschein\n" << "0) Beenden\n"; | |
| // getch() waits for a key press then returns ascii value of the input | |
| // In Ascii 0 is 48, 1 is 49, 2 is 50 etc. | |
| menuinput = getch() - 48; | |
| system("cls"); | |
| switch(menuinput) | |
| { | |
| case 0: | |
| loop = false; | |
| break; | |
| case 1: | |
| // program is stored in its own function and run once its called to do so | |
| // function is a void type and would return nothing | |
| rente(); | |
| cout << "Press any key to continue..."; | |
| getch(); | |
| break; | |
| case 2: | |
| wohnung(); | |
| cout << "Press any key to continue..."; | |
| getch(); | |
| break; | |
| case 3: | |
| fuhrerschein(); | |
| cout << "Press any key to continue..."; | |
| getch(); | |
| break; | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment