add Wellenlaengen-rechner
This commit is contained in:
		
							parent
							
								
									b8dd6e7ddb
								
							
						
					
					
						commit
						e116fb4e42
					
				@ -16,9 +16,6 @@ make
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### Windows
 | 
					### Windows
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1) Lade das Repository als zip-Datei herunter.
 | 
					Mit dem Aktuellen Makefile nur mit [Cygwin](https://www.cygwin.com/) möglich.
 | 
				
			||||||
2) Entpacke die Datei.
 | 
					
 | 
				
			||||||
3) Öffne das cmd und gehe in den Ordner `Photonics-Helper`.
 | 
					 | 
				
			||||||
4) Kompiliere das Programm mit `mingw32-make`.
 | 
					 | 
				
			||||||
5) Starte die Datei `Photonics-Helper.exe`.
 | 
					 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
 | 
				
			|||||||
@ -152,7 +152,6 @@ int Flugi() {
 | 
				
			|||||||
    // close file
 | 
					    // close file
 | 
				
			||||||
    fclose(file);
 | 
					    fclose(file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
    // Output
 | 
					    // Output
 | 
				
			||||||
    printf("\nDie Datei wurde in %d Zeilen eingelesen:\n", line_count);
 | 
					    printf("\nDie Datei wurde in %d Zeilen eingelesen:\n", line_count);
 | 
				
			||||||
    for (int i = 0; i < line_count; i++) {
 | 
					    for (int i = 0; i < line_count; i++) {
 | 
				
			||||||
@ -162,7 +161,6 @@ int Flugi() {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //char question[2][50]; //= {"Schaffen wir das? (1 = Ja, 0 = Nein)", "Wie geht das? (1 = Einfach, 0 = Schwer)"};
 | 
					    //char question[2][50]; //= {"Schaffen wir das? (1 = Ja, 0 = Nein)", "Wie geht das? (1 = Einfach, 0 = Schwer)"};
 | 
				
			||||||
    //int answer[2] = {1, 0};
 | 
					    //int answer[2] = {1, 0};
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										136
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,136 @@
 | 
				
			|||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <ctype.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Funktion, um einen String in Kleinbuchstaben umzuwandeln
 | 
				
			||||||
 | 
					void zuKleinbuchstaben(char* str) {
 | 
				
			||||||
 | 
					    for (int i = 0; str[i]; i++) {
 | 
				
			||||||
 | 
					        str[i] = tolower(str[i]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Funktion, um die Wellenlänge einer Farbe auszugeben
 | 
				
			||||||
 | 
					int value = 0;
 | 
				
			||||||
 | 
					int failcount = 0;
 | 
				
			||||||
 | 
					int returncode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int Wellenlaenge(const char* color) {
 | 
				
			||||||
 | 
					    if (strcmp(color, "rot") == 0) {
 | 
				
			||||||
 | 
					        printf("Die Wellenlänge von Rot liegt bei etwa 650-780 nm.\n");
 | 
				
			||||||
 | 
					    } else if (strcmp(color, "orange") == 0) {
 | 
				
			||||||
 | 
					        printf("Die Wellenlänge von Orange liegt bei etwa 585-650 nm.\n");
 | 
				
			||||||
 | 
					    } else if (strcmp(color, "gelb") == 0) {
 | 
				
			||||||
 | 
					        printf("Die Wellenlänge von Gelb liegt bei etwa 575-585 nm.\n");
 | 
				
			||||||
 | 
					    } else if (strcmp(color, "grün") == 0 || strcmp(color, "gruen") == 0) {
 | 
				
			||||||
 | 
					        printf("Die Wellenlänge von Grün liegt bei etwa 490-575 nm.\n");
 | 
				
			||||||
 | 
					    } else if (strcmp(color, "blau") == 0) {
 | 
				
			||||||
 | 
					        printf("Die Wellenlänge von Blau liegt bei etwa 450-490 nm.\n");
 | 
				
			||||||
 | 
					    } else if (strcmp(color, "violett") == 0) {
 | 
				
			||||||
 | 
					        printf("Die Wellenlänge von Violett liegt bei etwa 380-420 nm.\n");
 | 
				
			||||||
 | 
					    } else if (strcmp(color, "q") == 0) {
 | 
				
			||||||
 | 
					        return 10;
 | 
				
			||||||
 | 
					    } else if (failcount >= 5) {
 | 
				
			||||||
 | 
					        return 20;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        printf("Unbekannte Farbe oder keine Wellenlängeninformation verfügbar.\n");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    failcount++;
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Funktion, um die Farbe einer Wellenlänge auszugeben
 | 
				
			||||||
 | 
					int wavelenght = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void printColor(int wavelength) {
 | 
				
			||||||
 | 
					    switch (wavelength) {
 | 
				
			||||||
 | 
					        case 620 ... 750: // Range for red
 | 
				
			||||||
 | 
					            printf("Das Licht dieser Wellenlänge ist Rot\n");
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 590 ... 619: // Range for orange
 | 
				
			||||||
 | 
					            printf("Das Licht dieser Wellenlänge ist Orange\n");
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 570 ... 581: // Range for yellow
 | 
				
			||||||
 | 
					            printf("Das Licht dieser Wellenlänge ist Gelb\n");
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 495 ... 569: // Range for green
 | 
				
			||||||
 | 
					            printf("Das Licht dieser Wellenlänge ist Grün\n");
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 450 ... 494: // Range for blue
 | 
				
			||||||
 | 
					            printf("Das Licht dieser Wellenlänge ist Blau\n");
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case 380 ... 449: // Range for violet
 | 
				
			||||||
 | 
					            printf("Das Licht dieser Wellenlänge ist Violett\n");
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Main Programm
 | 
				
			||||||
 | 
					int Wellenlaengen_rechner_main() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    printf("Guten Tag.\nSie mögen Farben? Dann sind Sie hier genau richtig. Dieses Programm zeigt Ihnen nähmlich den Zusammenhang zwischen der Wellenlänge und der Farbe von Licht.\n");
 | 
				
			||||||
 | 
					    int modus = 0;
 | 
				
			||||||
 | 
					    int failcount = 0;
 | 
				
			||||||
 | 
					    int returncode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char auswahl[21] = {0};
 | 
				
			||||||
 | 
					    long wavelength = 0;
 | 
				
			||||||
 | 
					    char *endptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (1) {
 | 
				
			||||||
 | 
					        printf("\nFalls Sie die Lichtfarbe des emittierten Lichtes erfahren wollen, drücken Sie die Taste 1. Wenn Sie die Wellenlänge einer bestimmten Lichtfarbe interessiert, drücken Sie die Taste 2.\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        scanf("%20s", auswahl);
 | 
				
			||||||
 | 
					        modus = strtol((const char*)auswahl, &endptr, 10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (*endptr != 0){
 | 
				
			||||||
 | 
					            modus = -1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (*endptr == 'q'){
 | 
				
			||||||
 | 
					            return 10;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Ausgabe der Farbe
 | 
				
			||||||
 | 
					        if (modus==1) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            printf("Bitte geben Sie eine Wellenlänge ein (in nm): ");
 | 
				
			||||||
 | 
					            scanf("%20s", auswahl);
 | 
				
			||||||
 | 
					            wavelength = strtol((const char*)auswahl, &endptr, 10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (*endptr != 0){
 | 
				
			||||||
 | 
					                wavelength = -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (*endptr == 'q'){
 | 
				
			||||||
 | 
					                return 10;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            printColor(wavelength);
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Ausgabe der Wellenlänge
 | 
				
			||||||
 | 
					        else if (modus==2) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            char color[50];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            printf("Bitte geben Sie eine Farbe ein (z. B. Rot, Orange, Gelb, Grün, Blau, Violett): ");
 | 
				
			||||||
 | 
					            scanf("%49s", color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Funktion für Eingabe in Kleinbuchstaben umwandeln abrufen
 | 
				
			||||||
 | 
					            zuKleinbuchstaben(color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Funktion für Ausgabe der Wellenlänge abrufen
 | 
				
			||||||
 | 
					            returncode = Wellenlaenge(color);
 | 
				
			||||||
 | 
					            if (returncode == 10){
 | 
				
			||||||
 | 
					                return 10;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Ungültige Eingabe
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            printf("Bitte geben Sie die Nummer eins (1) oder zwei (2) ein. Nichts anderes!!!");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										7
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/Flugi-vz/Rechner_Wellenlaenge2.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					#ifndef Rechner_Wellenlaenge2_H_ 
 | 
				
			||||||
 | 
					#define Rechner_Wellenlaenge2_H_ 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   int Wellenlaengen_rechner_main();
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@ -33,8 +33,9 @@ Datum: 04.12.2024
 | 
				
			|||||||
// import sub programme
 | 
					// import sub programme
 | 
				
			||||||
#include "Ramen-vz/Ramen_Physik.h"
 | 
					#include "Ramen-vz/Ramen_Physik.h"
 | 
				
			||||||
#include "Fehlenden-vz/Fehlenden_Elektronik.h"
 | 
					#include "Fehlenden-vz/Fehlenden_Elektronik.h"
 | 
				
			||||||
#include "Wein-tz/Abbildungsrechner.h"
 | 
					 | 
				
			||||||
#include "Flugi-tz/Funktion_Flugi.h"
 | 
					#include "Flugi-tz/Funktion_Flugi.h"
 | 
				
			||||||
 | 
					#include "Flugi-vz/Rechner_Wellenlaenge2.h"
 | 
				
			||||||
 | 
					#include "Wein-tz/Abbildungsrechner.h"
 | 
				
			||||||
#include "Wein-vz/InformatikZusammenfassung.h"
 | 
					#include "Wein-vz/InformatikZusammenfassung.h"
 | 
				
			||||||
#include "Haenchen-vz/Haenchen_Drehmoment.h"
 | 
					#include "Haenchen-vz/Haenchen_Drehmoment.h"
 | 
				
			||||||
#include "test_prog.h"
 | 
					#include "test_prog.h"
 | 
				
			||||||
@ -191,11 +192,11 @@ void print_menu(int terminal_width, int terminal_height, int line){
 | 
				
			|||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (2 <= line && line < 4) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (2 <= line && line < 4) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  4 Drehmoment                    (vz) ┃", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
					        print_line("┃  4 Drehmoment                    (vz) ┃", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (3 <= line && line < 5) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (3 <= line && line < 5) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  5                               (vz) ┃", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
					        print_line("┃  5 Wellenlängenrechner           (vz) ┃", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (4 <= line && line < 6) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (4 <= line && line < 6) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  6 Abbildungsrechner             (tz) ┃", spaces, (5 <= line && line < 6) ? ";31": ";37");
 | 
					        print_line("┃  6 Abbildungsrechner             (tz) ┃", spaces, (5 <= line && line < 6) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (5 <= line && line < 7) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (5 <= line && line < 7) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  7 Numpy                         (tz) ┃", spaces, (6 <= line && line < 7) ? ";31": ";37");
 | 
					        print_line("┃  7 Quiz                          (tz) ┃", spaces, (6 <= line && line < 7) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (6 <= line && line < 8) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (6 <= line && line < 8) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  8                               (tz) ┃", spaces, (7 <= line && line < 8) ? ";31": ";37");
 | 
					        print_line("┃  8                               (tz) ┃", spaces, (7 <= line && line < 8) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (7 <= line && line < 9) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (7 <= line && line < 9) ? ";31": ";37");
 | 
				
			||||||
@ -248,7 +249,7 @@ void run_programm(int programm, int width, int height, bool *used){
 | 
				
			|||||||
        case 1: return_code = Fehlenden_Elektronik_main(); break;
 | 
					        case 1: return_code = Fehlenden_Elektronik_main(); break;
 | 
				
			||||||
        case 2: return_code = Informatik_main(); break;
 | 
					        case 2: return_code = Informatik_main(); break;
 | 
				
			||||||
        case 3: return_code = Haenchen_Drehmoment_main(); break;
 | 
					        case 3: return_code = Haenchen_Drehmoment_main(); break;
 | 
				
			||||||
        case 4: return_code = test_gruppe_programmname(); break;
 | 
					        case 4: return_code = Wellenlaengen_rechner_main(); break;
 | 
				
			||||||
        case 5: return_code = Abbildungsrechner(); break;
 | 
					        case 5: return_code = Abbildungsrechner(); break;
 | 
				
			||||||
        case 6: return_code = Flugi(); break;
 | 
					        case 6: return_code = Flugi(); break;
 | 
				
			||||||
        case 7: return_code = test_gruppe_programmname(); break;
 | 
					        case 7: return_code = test_gruppe_programmname(); break;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user