#include #include #include #include using namespace std; const float PI = 3.141592653f; void calcAngle(void), calcCote(void), coterAngles(void); int main(void) { // Début du programme bool boucleProg(true); // Booléen vrai while(boucleProg) { // Début du menu du programme // Début du while cout << "\t\t\t********** TRIGONOMETRIE **********" << endl << endl; short choix(0); cout << "1 - Calculez cos, sin ou tan d'un angle connu." << endl << "2 - Calculez un angle connaissant cos, sin ou tan." << endl << "3 - Calculez un coter du triangle, en connaissant un coter ET un angle." << endl << "4 - Quitter le programme." << endl << endl << "Votre choix : "; cin >> choix; while(choix < 1 || choix > 4) { // Tant que choix inférieur à 1 ou supérieur à 3 écrire : Veuillez ressaisir un choix entre...... cout << "Veuillez ressaisir un choix entre 1 et 4 compris : "; cin >> choix; } // Fin du menu du programme switch(choix) { // Début du switch case 1: { // Appel de la fonction calcAngle() system("cls"); calcAngle(); break; } case 2: { // Appel de la fonction calcCote() system("cls"); calcCote(); break; } case 3: { // Appel de la fonction coterAngles() system("cls"); coterAngles(); break; } case 4: { // Fin de programme avec décompte de 5 secondes boucleProg = false; short tps(3); cout << endl << "Fin du programme dans 3 secondes : " << endl << endl; while(tps > 0) { cout << tps << " secondes..." << endl; Sleep(1000); tps--; } break; } } // Fin du switch } // Fin du while return 0; } // Fin du programme // Fonction qui calcule un angle void calcAngle() { bool calcAng(true); while(calcAng) { short choix02(0); cout << "***** Calculez un angle *****" << endl << endl; cout << "1 - Cosinus d'un angle." << endl << "2 - Sinus d'un angle." << endl << "3 - Tangente d'un angle." << endl << "4 - Retour au menu." << endl << endl << "Votre choix : "; cin >> choix02; while(choix02 < 1 || choix02 > 4) { cout << "Veuillez ressaisir un choix entre 1 et 4 compris : "; cin >> choix02; } switch(choix02) { case 1: { // Cosinus d'un angle system("cls"); float angle(0), resultat(0); cout << "***** Cosinus d'un angle *****" << endl << endl; cout << "Cosinus de : "; cin >> angle; resultat=cos(angle*PI/180); cout << endl << "En degres : " << fixed << setprecision(6) << resultat << endl; cout << "En radians : " << fixed << setprecision(6) << resultat*180/PI << endl << endl; system("PAUSE"); system("cls"); break; } case 2: { // Sinus d'un angle system("cls"); float angle(0), resultat(0); cout << "***** Sinus d'un angle *****" << endl << endl; cout << "Sinus de : "; cin >> angle; resultat=sin(angle*PI/180); cout << endl << "En degres : " << fixed << setprecision(6) << resultat << endl; cout << "En radians : " << fixed << setprecision(6) << resultat*180/PI << endl << endl; system("PAUSE"); system("cls"); break; } case 3: { // Tangente d'un angle system("cls"); float angle(0), resultat(0); cout << "***** Tangente d'un angle *****" << endl << endl; cout << "Tangente de : "; cin >> angle; resultat=tan(angle*PI/180); cout << endl << "En degres : " << fixed << setprecision(6) << resultat << endl; cout << "En radians : " << fixed << setprecision(6) << resultat*180/PI << endl << endl; system("PAUSE"); system("cls"); break; } case 4: { calcAng = false; break; } } } system("cls"); } // Fonction qui calcule un le cosinus, le sinus ou la tangente void calcCote() { bool calcCo(true); while(calcCo) { short choix03(0); cout << "***** Calculez un angle connaissant cos, sin ou tan *****" << endl << endl << "1 - Avec cosinus." << endl << "2 - Avec sinus." << endl << "3 - Avec tangente." << endl << "4 - Retour au menu." << endl << endl << "Votre choix : "; cin >> choix03; while(choix03 < 1 || choix03 > 4) { cout << "Veuilliez ressaisir un choix entre 1 et 4 compris : "; cin >> choix03; } switch(choix03) { case 1: { // Calcul un angle avec le cosinus system("cls"); float angle(0), resultat(0); cout << "***** Angle avec cosinus *****" << endl << endl; cout << "Le cosinus de votre angle (a 0,001 pres) : "; cin >> angle; while(angle > 1) { cout << endl << "Le cosinus d'un angle ne peut dépasser 1 !" << endl << "Veuillez ressaisir le cosinus de votre angle : "; cin >> angle; } resultat=acos(angle); cout << endl << "En degres : " << fixed << setprecision(6) << resultat*180/PI << endl; cout << "En radians : " << fixed << setprecision(6) << resultat << endl << endl; system("PAUSE"); system("cls"); break; } case 2: { // Calcule un angle avec le sinus system("cls"); float angle(0), resultat(0); cout << "***** Angle avec sinus *****" << endl << endl; cout << "Le sinus de votre angle (a 0,001 pres) : "; cin >> angle; while(angle > 1) { cout << endl << "Le sinus d'un angle ne peut dépasser 1 !" << endl << "Veuillez ressaisir le sinus de votre angle : "; cin >> angle; } resultat=asin(angle); cout << endl << "En degres : " << fixed << setprecision(6) << resultat*180/PI << endl; cout << "En radians : " << fixed << setprecision(6) << resultat << endl << endl; system("PAUSE"); system("cls"); break; } case 3: { // Calcule un angle avec la tangente system("cls"); float angle(0), resultat(0); cout << "***** Angle avec tangente *****" << endl << endl; cout << "La tangente de votre angle (a 0,001 pres) : "; cin >> angle; resultat=atan(angle); cout << endl << "En degres : " << fixed << setprecision(6) << resultat*180/PI << endl; cout << "En radians : " << fixed << setprecision(6) << resultat << endl << endl; system("PAUSE"); system("cls"); break; } case 4: { system("cls"); calcCo = false; break; } } } system("cls"); } void coterAngles() { // Fonction qui calcule un coté bool coterAng(true); while(coterAng) { short choix04(2); cout << "***** Calculez un coter du triangle, en connaissant un coter ET un angle *****" << endl << endl << "1 - Calculez un coter avec le COSINUS." << endl << "2 - Calculez un coter avec le SINUS." << endl << "3 - Calculez un coter avec la TANGENTE." << endl << "4 - Retour au menu." << endl << endl << "Votre choix : "; cin >> choix04; while(choix04 < 1 || choix04 > 4) { cout << "Ressaisissez un choix entre 1 et 4 compris : "; cin >> choix04; } switch(choix04) { case 1: { // Le cosinus system("cls"); short newchoix01(0); cout << "***** Calculez un coter avec le COSINUS *****" << endl << endl << "1 - En connaissant le cote adjacent (pour trouver l'hypothenuse)." << endl << "2 - En connaissant l'hypothenuse (pour trouver le cote adjacent)." << endl << endl << "Votre choix : "; cin >> newchoix01; while(newchoix01 < 1 || newchoix01 > 2) { cout << "Ressaisissez votre choix : "; cin >> newchoix01; } if(newchoix01 == 1) { // Pour trouver l'hypothénuse system("cls"); cout << "*** Coter adjacent --> Hypothenuse ***" << endl << endl; float angle(0), coter(0), resultat(0); cout << "Combien vaut votre angle ? "; cin >> angle; cout << "Combien mesure le cote adjacent a cette angle ? "; cin >> coter; resultat=coter/cos(angle*PI/180); cout << endl << "L'hypothenuse mesure " << fixed << setprecision(6) << resultat << "(unite de mesure)." << endl << endl; system("PAUSE"); } else if(newchoix01 == 2) { // Pour trouver le coter adjacent system("cls"); cout << "*** Hypothenuse --> Coter adjacent" << endl << endl; float angle(0), coter(0), resultat(0); cout << "Combien vaut votre angle ? "; cin >> angle; cout << "Combien mesure l'hypothenuse du triangle ? "; cin >> coter; resultat=coter*cos(angle*PI/180); cout << endl << "Le cote adjacent mesure " << fixed << setprecision(6) << resultat << "(unite de mesure)." << endl << endl; system("PAUSE"); } system("cls"); break; } case 2: { // Le sinus system("cls"); short newchoix02(0); cout << "***** Calculez un coter avec le SINUS *****" << endl << endl << "1 - En connaissant le cote oppose (pour trouver l'hypothenuse)." << endl << "2 - En connaissant l'hypothenuse (pour trouver le coter oppose)." << endl << endl << "Votre choix : "; cin >> newchoix02; while(newchoix02 < 1 || newchoix02 > 2) { cout << "Ressaisissez votre choix : "; cin >> newchoix02; } if(newchoix02 == 1) { // Pour trouver l'hypothénuse system("cls"); cout << "*** Coter oppose --> Hypothenuse ***" << endl << endl; float angle(0), coter(0), resultat(0); cout << "Combien vaut votre angle ? "; cin >> angle; cout << "Combien mesure le cote oppose a cette angle ? "; cin >> coter; resultat=coter/sin(angle*PI/180); cout << endl << "Le cote oppose mesure " << fixed << setprecision(6) << resultat << "(unite de mesure)." << endl << endl; system("PAUSE"); } else if(newchoix02 == 2) { // Pour trouver le coter oppose system("cls"); cout << "*** Hypothenuse --> Coter oppose ***" << endl << endl; float angle(0), coter(0), resultat(0); cout << "Combien vaut votre angle ? "; cin >> angle; cout << "Combien mesure l'hypothenuse du triangle ? "; cin >> coter; resultat=coter*sin(angle*PI/180); cout << endl << "L'hypothenuse mesure " << fixed << setprecision(6) << resultat << "(unite de mesure)." << endl << endl; system("PAUSE"); } system("cls"); break; } case 3: { // La tangente system("cls"); short newchoix03(0); cout << "***** Calculez un coter avec la TANGENTE *****" << endl << endl << "1 - En connaissant le cote oppose (pour trouver le cote adjacent)." << endl << "2 - En connaissant le cote adjacent (pour trouver le coter oppose)." << endl << endl << "Votre choix : "; cin >> newchoix03; while(newchoix03 < 1 || newchoix03 > 2) { cout << "Ressaisissez votre choix : "; cin >> newchoix03; } if(newchoix03 == 1) { // Pour trouver le coter adjacent system("cls"); cout << "*** Coter oppose --> Coter adjacent ***" << endl << endl; float angle(0), coter(0), resultat(0); cout << "Combien vaut votre angle ? "; cin >> angle; cout << "Combien mesure le cote oppose a cette angle ? "; cin >> coter; resultat=coter/tan(angle*PI/180); cout << endl << "Le cote adjcent mesure " << fixed << setprecision(6) << resultat << "(unite de mesure)." << endl << endl; system("PAUSE"); } else if(newchoix03 == 2) { // Pour trouver le coter oppose system("cls"); cout << "*** Coter Adjacent --> Coter oppose ***" << endl << endl; float angle(0), coter(0), resultat(0); cout << "Combien vaut votre angle ? "; cin >> angle; cout << "Combien mesure le cote adjacent a cette angle ? "; cin >> coter; resultat=coter*tan(angle*PI/180); cout << endl << "Le cote oppose mesure " << fixed << setprecision(6) << resultat << "(unite de mesure)." << endl << endl; system("PAUSE"); } system("cls"); break; } case 4: { system("cls"); coterAng = false; break; } } } }