[C/C++] Projekt läuft nicht !

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von papst^, 22. April 2009 .

Schlagworte:
Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 22. April 2009
    Projekt läuft nicht !

    So hat sich schon erledigt. Danke trozdem.
     
  2. 22. April 2009
    AW: Projekt läuft nicht !

    jetzt läufts zumindest mal ... denke aber da hast noch einiges an arbeit vor dir code4 hat in der funktion z.b. noch keine belegung, jetzt kommt null raus!

    Code:
    /**
    *Eingabe & Überprüfung der Farben
    *
    *@autor Gruppe 
    *@version v 1.2 22.04.2009
    */
    
    // Präprozessor-Direktiven
    #include <stdio.h>
    #include <conio.h>
    #include <math.h>
    #include <string.h>
    #include <stdlib.h>
    
    
    void inputColors(void);
    void colorToInt(void);
    float calcResistance(void);
    float calcTolerance(float resistance);
    void printResult(float resistance, float tolerance);
    
    
    char color1[20];
    char color2[20];
    char color3[20];
    char color4[20];
    
    int code1;
    int code2;
    int code3;
    int code4;
    
    // Hauptfunktion
    int main(void) {
    
    // Vereinbarungsteil
    
     float resistance, tolerance;
     float resistance1, resistance2;
     float widerstandswert, tolaranz_erg;
     //float resistance;
    
    
    // Anweisungsteil
    
     //textcolor(RED);
    
     inputColors();
     colorToInt();
     
     widerstandswert = calcResistance();
     
     tolaranz_erg = calcTolerance(widerstandswert);
     printResult(widerstandswert, tolaranz_erg);
    
     printf("\n\nWeiter mit beliebiger Taste ...");
     getch();
     return 0;
    }
    
    
    void inputColors( void ) {
    
    // Vereinbarungsteil
     char hilfColor[10];
     bool flag = false ;
    
    
    // Anweisungsteil
     printf("\nGeben Sie die Farben der Ringe von links nach rechts ein !");
    
    //-------------------------Farbe 1---------------------------------
    
     printf("\nFarbe 1: ");
     gets(hilfColor);
     fflush(stdin);
    
     do {
     if(strcmp(hilfColor, "schwarz") != 0 && strcmp(hilfColor, "braun") != 0 && strcmp(hilfColor, "rot") != 0 && strcmp(hilfColor, "orange") != 0 && strcmp(hilfColor, "gelb") != 0 && strcmp(hilfColor, "gruen") != 0 && strcmp(hilfColor, "blau") != 0 && strcmp(hilfColor, "violett") != 0 && strcmp(hilfColor, "grau") != 0 && strcmp(hilfColor, "weiß") != 0 ) {
     cprintf("\nFalsche Eingabe !!!");
     printf("\n\nErneut Farbe 1: ");
     gets(hilfColor);
     fflush(stdin);
     }else {
     strcpy(hilfColor, color1);
     flag = true;
     }
     } while ( flag == false );
    
    //-------------------------Farbe 2---------------------------------
     flag = false;
    
     printf("\nFarbe 2: ");
     gets(hilfColor);
     fflush(stdin);
    
     do {
     if(strcmp(hilfColor, "schwarz") != 0 && strcmp(hilfColor, "braun") != 0 && strcmp(hilfColor, "rot") != 0 && strcmp(hilfColor, "orange") != 0 && strcmp(hilfColor, "gelb") != 0 && strcmp(hilfColor, "gruen") != 0 && strcmp(hilfColor, "blau") != 0 && strcmp(hilfColor, "violett") != 0 && strcmp(hilfColor, "grau") != 0 && strcmp(hilfColor, "weiß") != 0 ) {
     cprintf("\nFalsche Eingabe !!!");
     printf("\n\nErneut Farbe 2: ");
     gets(hilfColor);
     fflush(stdin);
     }
     else {
     strcpy(hilfColor, color2);
     flag = true;
     }
     } while ( flag == false );
    
    //-------------------------Farbe 3---------------------------------
     flag = false;
    
     printf("\nFarbe 3: ");
     gets(hilfColor);
     fflush(stdin);
     do {
     if( strcmp(hilfColor, "scharz") != 0 && strcmp(hilfColor, "braun") != 0 && strcmp(hilfColor, "rot") != 0 && strcmp(hilfColor, "orange") != 0 && strcmp(hilfColor, "gelb") != 0 && strcmp(hilfColor, "gruen") != 0 && strcmp(hilfColor, "blau") != 0 && strcmp(hilfColor, "gold") != 0 && strcmp(hilfColor, "silber") != 0) {
     cprintf("\nFalsche Eingabe !!!");
     printf("\n\nErneut Farbe 3: ");
     gets(hilfColor);
     fflush(stdin);
     }
     else {
     strcpy(hilfColor, color3);
     flag = true;
     }
     } while ( flag == false );
    //-------------------------Farbe 4---------------------------------
     flag = false;
    
     printf("\nFarbe 4: ");
     gets(hilfColor);
     fflush(stdin);
     do {
     if( strcmp(hilfColor, "braun") != 0 && strcmp(hilfColor, "rot") != 0 && strcmp(hilfColor, "gold") != 0 && strcmp(hilfColor, "silber") != 0 ) {
     cprintf("\nFalsche Eingabe !!!");
     printf("\n\nErneut Farbe 4: ");
     gets(hilfColor);
     fflush(stdin);
     }
     else {
     strcpy(hilfColor, color4);
     flag = true;
     }
     } while ( flag == false );
    }
    
    void colorToInt(void){
    
     if(strcmp(color1, "schwarz") == 0) {
     code1 = 0;
     }
     if(strcmp(color1, "braun") == 0) {
     code1 = 1;
     }
     if(strcmp(color1, "rot") == 0) {
     code1 = 2;
     }
     if(strcmp(color1, "orange") == 0) {
     code1 = 3;
     }
     if(strcmp(color1, "gelb") == 0) {
     code1 = 4;
     }
     if(strcmp(color1, "grün") == 0) {
     code1 = 5;
     }
     if(strcmp(color1, "blau") == 0) {
     code1 = 6;
     }
     if(strcmp(color1, "violett") == 0) {
     code1 = 7;
     }
     if(strcmp(color1, "grau") == 0) {
     code1 = 8;
     }
     if(strcmp(color1, "weiss") == 0) {
     code1 = 9;
     }
     if(strcmp(color1, "gold") == 0) {
     code1 = 10;
     }
     if(strcmp(color1, "silber") == 0) {
     code1 = 11;
     }
     if(strcmp(color1, " ") == 0) {
     code1 = 12;
     }
    
    
     if(strcmp(color2, "schwarz") == 0) {
     code2 = 0;
     }
     if(strcmp(color2, "braun") == 0) {
     code2 = 1;
     }
     if(strcmp(color2, "rot") == 0) {
     code2 = 2;
     }
     if(strcmp(color2, "orange") == 0) {
     code2 = 3;
     }
     if(strcmp(color2, "gelb") == 0) {
     code2 = 4;
     }
     if(strcmp(color2, "grün") == 0) {
     code2 = 5;
     }
     if(strcmp(color2, "blau") == 0) {
     code2 = 6;
     }
     if(strcmp(color2, "violett") == 0) {
     code2 = 7;
     }
     if(strcmp(color2, "grau") == 0) {
     code2 = 8;
     }
     if(strcmp(color2, "weiss") == 0) {
     code2 = 9;
     }
     if(strcmp(color2, "gold") == 0) {
     code2 = 10;
     }
     if(strcmp(color2, "silber") == 0) {
     code2 = 11;
     }
     if(strcmp(color2, " ") == 0) {
     code2 = 12;
     }
    
    
    
     if(strcmp(color3, "schwarz") == 0) {
     code3 = 0;
     }
     if(strcmp(color3, "braun") == 0) {
     code3 = 1;
     }
     if(strcmp(color3, "rot") == 0) {
     code3 = 2;
     }
     if(strcmp(color3, "orange") == 0) {
     code3 = 3;
     }
     if(strcmp(color3, "gelb") == 0) {
     code3 = 4;
     }
     if(strcmp(color3, "grün") == 0) {
     code3 = 5;
     }
     if(strcmp(color3, "blau") == 0) {
     code3 = 6;
     }
     if(strcmp(color3, "violett") == 0) {
     code3 = 7;
     }
     if(strcmp(color3, "grau") == 0) {
     code3 = 8;
     }
     if(strcmp(color3, "weiss") == 0) {
     code3 = 9;
     }
     if(strcmp(color3, "gold") == 0) {
     code3 = 10;
     }
     if(strcmp(color3, "silber") == 0) {
     code3 = 11;
     }
     if(strcmp(color3, " ") == 0) {
     code3 = 12;
     }
    
     if(strcmp(color4, "schwarz") == 0) {
     code4 = 0;
     }
     if(strcmp(color4, "braun") == 0) {
     code4 = 1;
     }
     if(strcmp(color4, "rot") == 0) {
     code4 = 2;
     }
     if(strcmp(color4, "orange") == 0) {
     code4 = 3;
     }
     if(strcmp(color4, "gelb") == 0) {
     code4 = 4;
     }
     if(strcmp(color4, "grün") == 0) {
     code4 = 5;
     }
     if(strcmp(color4, "blau") == 0) {
     code4 = 6;
     }
     if(strcmp(color4, "violett") == 0) {
     code4 = 7;
     }
     if(strcmp(color4, "grau") == 0) {
     code4 = 8;
     }
     if(strcmp(color4, "weiss") == 0) {
     code4 = 9;
     }
     if(strcmp(color4, "gold") == 0) {
     code4 = 10;
     }
     if(strcmp(color4, "silber") == 0) {
     code4 = 11;
     }
     if(strcmp(color4, " ") == 0) {
     code4 = 12;
     }
    }
    
    
    float calcResistance(void) {
    
     float erg1, widerstandswert;
    
    
     if (code3 == 0){
     code3 = 1;
     }
     else if (code3 == 1){
     code3 = 10;
     }
     else if (code3 == 2){
     code3 = 100;
     }
     else if (code3 == 3){
     code3 = 1000;
     }
     else if (code3 == 4){
     code3 = 10000;
     }
     else if (code3 == 5){
     code3 = 100000;
     }
     else if (code3 == 6){
     code3 = 1000000;
     }
     else if (code3 == 7){
     code3 = 10000000;
     }
     else if (code3 == 10){
     code3 = 0.1;
     }
     else if (code3 == 11){
     code3 = 0.01;
     }
     else if (code3 == 12){
     printf("ERROR: Widerstand nicht vorhanden!!!");
     }
     erg1 = code1*10 + code2;
     widerstandswert = erg1 * code3;
     return widerstandswert;
    }
    
    float calcTolerance(float widerstandswert) {
    
    // Vereinbarungsteil
     float tolerance= 0, tolaranz_erg = 0;
    
    // Anweisungsteil
     switch(code4) {
     case 1: tolerance = 0.01;
     break;
     case 2: tolerance = 0.02;
     break;
     case 5: tolerance = 0.005;
     break;
     case 6: tolerance = 0.025;
     break;
     case 7: tolerance = 0.001;
     break;
     case 10: tolerance = 0.05;
     break;
     case 11: tolerance = 0.1;
     break;
     case 12: tolerance = 0.2;
     break;
     }
     tolaranz_erg = widerstandswert * tolerance;
     return tolaranz_erg;
    }
    
    void printResult(float widerstandswert, float tolaranz_erg) {
    
    // Vereinbarungsteil
    
     float resistance1, resistance2;
    // Anweisungsteil
     resistance2 = widerstandswert + tolaranz_erg;
     resistance1 = widerstandswert - tolaranz_erg;
     printf("\n----------------Ergebnis----------------------------------\n");
     printf("Farben: %s - %s - %s - %s", color1, color2, color3, color4);
     printf("\nWiderstandswert: %.2f OHM", widerstandswert);
     printf("\nWiderstandsbereich: %.2f OHM bis %.2f OHM", resistance1, resistance2);
     getch();
    }
    
     
  3. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.