Advertisement
Guest User

Euro/Dollar

a guest
May 22nd, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *args[])
  7. {
  8.     start:
  9.     char mtype, again;
  10.     float value, other_value;
  11.     cout << "--------------------------------------------------------------------" << endl;
  12.     cout << "Euro->Dollar->Euro [Umrechner von Euro zu Dollar und umgekehrt]" << endl;
  13.     cout << "--------------------------------------------------------------------" << endl << endl;
  14.     retype_mtype:
  15.     cout << "Möchtest du den Euro- oder den Dollar-Betrag angeben? [e/d]: ";
  16.     cin >> mtype;
  17.     fflush(stdin);
  18.     if (mtype != 'e' && mtype != 'd') goto retype_mtype;
  19.     cout << endl << "Bitte gib einen Betrag in " << (mtype == 'e' ? ("Euro") : (mtype == 'd' ? ("Dollar") : (""))) << " an: ";
  20.     cin >> value;
  21.     fflush(stdin);
  22.     switch (mtype)
  23.     {
  24.         case 'e': {
  25.             other_value = value * 1.1f;
  26.             break;
  27.         }
  28.         case 'd': {
  29.             other_value = value / 1.1f;
  30.             break;
  31.         }
  32.     }
  33.     cout << endl << value << (mtype == 'e' ? (" Euro") : (mtype == 'd' ? (" Dollar") : (""))) << " sind umgerechnet " << other_value << (mtype == 'e' ? (" Dollar") : (mtype == 'd' ? (" Euro") : (""))) << endl;
  34.     retype_again:
  35.     cout << "Möchtest du noch mehr umrechnen? [y/n]: ";
  36.     cin >> again;
  37.     fflush(stdin);
  38.     if (again != 'y' && again != 'n') goto retype_again;
  39.     else if (again == 'y') goto start;
  40.     else if (again == 'n') return(0);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement