Suche befehl !

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von ra!d, 3. Januar 2006 .

Schlagworte:
  1. 3. Januar 2006
    Hi
    Ich hab mal so Anfänger Sachen geschrieben wie ne Addition und so .. jetzt würde ich gerne nen "Taschenrechner" machen .. ich weis nur nicht wie !
    Soweit bin ich schon
    Code:
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main () {
     int 1;
     int 2;
     int 3;
     int 4;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Programmiert von eveR ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###### Taschenrechner #######"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"### Bitte wählen sie... ###"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"1: Addition"<<endl;
     cout<<"2: Subtraktion"<<endl;
     cout<<"3: Multiplikation"<<endl;
     cout<<"4: Division"<<endl; 
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     
    
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main(){
     int Summand1;
     int Summand2;
     int Summe;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Programmiert von eveR ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"######## Addition #########"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 1 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cin>>Summand1;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 2 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cin>>Summand2;
     Summe=Summand1+Summand2;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<" Das Ergebnis lautet "<<Summe<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     system("pause");
     return true;
     }
     
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main(){
     int Divident;
     int Divisor;
     int Division;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Programmiert von eveR ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"######## Division #########"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 1 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cin>>Divident;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 2 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cin>>Divisor;
     Division=Divident/Divisor;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<" Das Ergebnis lautet "<<Division<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     system("pause");
     return true;
     }
    
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main(){
     int Faktor1;
     int Faktor2;
     int Produkt;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Programmiert von eveR ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"##### Multiplikation ######"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 1 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cin>>Faktor1;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 2 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cin>>Faktor2;
     Produkt=Faktor1*Faktor2;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<" Das Produkt lautet "<<Produkt<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     system("pause");
     return true;
     }
    
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main(){
     int Minuend;
     int Subtrahend;
     int Differenz;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Programmiert von eveR ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###### Subtraktion ########"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 1 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cin>>Minuend;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"## Bitte Zahl 2 eingeben ##"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cin>>Subtrahend;
     Differenz=Minuend-Subtrahend;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     cout<<" Das Ergebnis lautet "<<Differenz<<endl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cout<<"---------------------------"<<endl;
     system("pause");
     return true;
     }
    
    Ich möchte jetzt das am anfang halt gefragt wir was möchte man machen .. hab ich ja auch schon geschrieben ... und dann halt 1 2 3 oder 4 ! aber wie ??
    thx ra!d
     
  2. 3. Januar 2006
    Am besten wäre es mit einem Switch-Befehl..

    Code:
     int Auswahl;
     cout<<"---------------------------"<<endl;
     cout<<"###########################"<<endl;
     cin >> Auswahl
    
     switch (Auswahl) {
     case 1: //code für addition
     case 2: //code für subtraktion
     case 3: // code für multiplikation
     case 4: // code für division
    
     }
    
    
     
  3. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.