Abgabe_neu
Aufgabe_249.cpp@0:5cabd77ebde3, 2020-04-28 (annotated)
- Committer:
- gigo2191
- Date:
- Tue Apr 28 19:33:52 2020 +0000
- Revision:
- 0:5cabd77ebde3
Abgabe
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gigo2191 | 0:5cabd77ebde3 | 1 | /****************************************************************************** |
gigo2191 | 0:5cabd77ebde3 | 2 | |
gigo2191 | 0:5cabd77ebde3 | 3 | C++ Kurs BULME 19/20 SM |
gigo2191 | 0:5cabd77ebde3 | 4 | Aufgane 249 |
gigo2191 | 0:5cabd77ebde3 | 5 | Glücksspiel |
gigo2191 | 0:5cabd77ebde3 | 6 | Mario Neubauer |
gigo2191 | 0:5cabd77ebde3 | 7 | |
gigo2191 | 0:5cabd77ebde3 | 8 | *******************************************************************************/ |
gigo2191 | 0:5cabd77ebde3 | 9 | #include <stdio.h> |
gigo2191 | 0:5cabd77ebde3 | 10 | #include <iostream> |
gigo2191 | 0:5cabd77ebde3 | 11 | using namespace std; |
gigo2191 | 0:5cabd77ebde3 | 12 | |
gigo2191 | 0:5cabd77ebde3 | 13 | int main() |
gigo2191 | 0:5cabd77ebde3 | 14 | { |
gigo2191 | 0:5cabd77ebde3 | 15 | int Betrag; |
gigo2191 | 0:5cabd77ebde3 | 16 | int kontostand = 10000; |
gigo2191 | 0:5cabd77ebde3 | 17 | int zufall; |
gigo2191 | 0:5cabd77ebde3 | 18 | int zahl; |
gigo2191 | 0:5cabd77ebde3 | 19 | |
gigo2191 | 0:5cabd77ebde3 | 20 | srand (time(NULL)); |
gigo2191 | 0:5cabd77ebde3 | 21 | |
gigo2191 | 0:5cabd77ebde3 | 22 | |
gigo2191 | 0:5cabd77ebde3 | 23 | while(kontostand > 0) |
gigo2191 | 0:5cabd77ebde3 | 24 | { |
gigo2191 | 0:5cabd77ebde3 | 25 | printf("Betrag eingeben:\n"); |
gigo2191 | 0:5cabd77ebde3 | 26 | scanf("%d", &Betrag); |
gigo2191 | 0:5cabd77ebde3 | 27 | |
gigo2191 | 0:5cabd77ebde3 | 28 | if(Betrag <= kontostand) |
gigo2191 | 0:5cabd77ebde3 | 29 | { |
gigo2191 | 0:5cabd77ebde3 | 30 | printf("Zahl eingeben:\n"); |
gigo2191 | 0:5cabd77ebde3 | 31 | scanf("%d", &zahl); |
gigo2191 | 0:5cabd77ebde3 | 32 | |
gigo2191 | 0:5cabd77ebde3 | 33 | if(zahl < 10) |
gigo2191 | 0:5cabd77ebde3 | 34 | { |
gigo2191 | 0:5cabd77ebde3 | 35 | zufall = rand() %10; |
gigo2191 | 0:5cabd77ebde3 | 36 | printf("Eingegebene Zahl ist: %d, Zufallszahl ist: %d\n", zahl, zufall); |
gigo2191 | 0:5cabd77ebde3 | 37 | kontostand = kontostand - Betrag; |
gigo2191 | 0:5cabd77ebde3 | 38 | |
gigo2191 | 0:5cabd77ebde3 | 39 | if(zahl == zufall) |
gigo2191 | 0:5cabd77ebde3 | 40 | kontostand = kontostand + (Betrag*9); |
gigo2191 | 0:5cabd77ebde3 | 41 | printf("Aktueller Kontostand: %d\n", kontostand); |
gigo2191 | 0:5cabd77ebde3 | 42 | |
gigo2191 | 0:5cabd77ebde3 | 43 | } |
gigo2191 | 0:5cabd77ebde3 | 44 | else |
gigo2191 | 0:5cabd77ebde3 | 45 | printf("falsche Eingabe\n"); |
gigo2191 | 0:5cabd77ebde3 | 46 | } |
gigo2191 | 0:5cabd77ebde3 | 47 | else |
gigo2191 | 0:5cabd77ebde3 | 48 | printf("Der Betrag it höher als der Kontostand\n"); |
gigo2191 | 0:5cabd77ebde3 | 49 | } |
gigo2191 | 0:5cabd77ebde3 | 50 | return 0; |
gigo2191 | 0:5cabd77ebde3 | 51 | } |
gigo2191 | 0:5cabd77ebde3 | 52 |