Advertisement
Jupiter_Crafter

main_bruch.cpp

Apr 23rd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include "bruch.h"
  3. #include<limits>
  4.  
  5. using namespace std;
  6.  
  7. int integer_input()
  8. {
  9.     int number;
  10.     while(!(cin >> number)) {
  11.          cin.clear();
  12.          if (cin.get() != '\n')
  13.          {
  14.              cout << "Ganze Zahlen, Fließkommerzahlen werden abgeschnitten:  ";
  15.              continue;
  16.          }
  17.     }
  18.     return number;
  19. }
  20.  
  21.  
  22.  
  23. int main()
  24. {
  25.     cout << "Nur GANZE Zahlen" << endl;
  26.     cout << endl << "Erster Bruch" << endl;
  27.     cout << "Zaehler 1: ";
  28.     int zaehler = integer_input();
  29.     cout << "Nenner 1: ";
  30.     int nenner = integer_input();
  31.     bruch B1(zaehler, nenner);
  32.     cout << endl << "Zweiter Bruch" << endl << endl;
  33.     cout << "Zaehler 2: ";
  34.     zaehler = integer_input();
  35.     cout << "Nenner 2: ";
  36.     nenner = integer_input();
  37.     bruch B2(zaehler, nenner);
  38.  
  39.  
  40.     cout << endl << "----------" << endl;
  41.     cout << "Berechnungen" << endl;
  42.     cout << "----------" << endl << endl;
  43.  
  44.     cout << "Addition: " << (B1 + B2).kuerzen() << endl;
  45.     cout << "Subtraktion: " << (B1 - B2).kuerzen() << endl;
  46.     cout << "Multiplikation: " << (B1 * B2).kuerzen() << endl;
  47.     cout << "Division: " << (B1 / B2).kuerzen() << endl;
  48.  
  49.  
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement