Advertisement
Guest User

lel

a guest
Oct 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1.  
  2. #define _CRT_SECURE_NO_WARNINGS 1
  3.  
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6.  
  7. int main()
  8. {
  9.  
  10. float tempIn, tempOut; //Variablen werden erstellt
  11. int unitIn, unitOut;
  12. int desiredConversion;
  13. char response;
  14.  
  15. printf("\n\nProgramm zur Umrechnung von Temperaturen\n");
  16. printf("----------------------------------------\n");
  17.  
  18. do {
  19.  
  20. printf("\nAus welchem Einheitensystem soll umgerechnet werden?\n\n");
  21. printf("1: grad C 2: grad F 3: K 4:Rø\n\n");
  22. printf("Ihre Wahl: ");
  23. scanf("%i",&unitIn); //Eingabeeinheitsystem wird gescannt
  24. while (getchar() != '\n');
  25.  
  26. printf("\nBitte geben Sie die umzurechnende Temperatur an: ");
  27. scanf("%f",&tempIn); //Wert der Temperatur wird gescannt
  28. while (getchar() != '\n');
  29.  
  30. printf("\nIn welches Einheitensystem soll umgerechnet werden?\n\n");
  31. printf("1: grad C 2: grad F 3: K 4:Rø\n\n");
  32.  
  33. printf("Ihre Wahl: ");
  34. scanf("%i",&unitOut); //Gewünschte Ausgabeeinheit wird gescannt
  35. while (getchar() != '\n');
  36.  
  37. desiredConversion = unitIn * 10 + unitOut; //cases werden gepickt je nach in und output
  38. switch(desiredConversion)
  39. {
  40. case 12: tempOut = (tempIn * 9.0 / 5.0) + 32.0;
  41. printf("\n\n%.2fgrad C = %.2fgrad F\n\n",tempIn,tempOut);
  42. break;
  43. case 13: tempOut = tempIn + 273.15;
  44. printf("\n\n%.2fgrad C = %.2fK\n\n",tempIn,tempOut);
  45. break;
  46. case 21: tempOut = (tempIn - 32.0) * 5.0 / 9.0;
  47. printf("\n\n%.2fgrad F = %.2fgrad C\n\n",tempIn,tempOut);
  48. break;
  49. case 23: tempOut = (tempIn - 32.0) * 5.0 / 9.0 + 273.15;
  50. printf("\n\n%.2fgrad F = %.2fK\n\n",tempIn,tempOut);
  51. break;
  52. case 31: tempOut = tempIn + 273.15;
  53. printf("\n\n%.2fK = %.2fgrad C\n\n",tempIn,tempOut);
  54. break;
  55. case 32: tempOut = (tempIn - 273.15) * 9.0 / 5.0 + 32.0;
  56. printf("\n\n%.2fK = %.2fgrad F\n\n",tempIn,tempOut);
  57. break;
  58.  
  59.  
  60. case 14: tempOut = tempIn * 21.0 / 40.0 + 7.5; //Roemer cases die ich hinzugefügt habe
  61. printf("\n\n%.2fC = %.2fgrad Rø\n\n",tempIn,tempOut);
  62. break;
  63. case 24: tempOut = (tempIn - 32.0) * 7.0 / 24.0 + 7.5;
  64. printf("\n\n%.2fF = %.2fgrad Rø\n\n",tempIn,tempOut);
  65. break;
  66. case 34: tempOut = (tempIn - 273.15) * 21.0 / 40.0 + 7.5;
  67. printf("\n\n%.2fK = %.2fgrad Rø\n\n",tempIn,tempOut);
  68. break;
  69. case 41: tempOut = (tempIn / (21.0 / 40.0) - 7.5);
  70. printf("\n\n%.2fRø = %.2fgrad C\n\n",tempIn,tempOut);
  71. break;
  72. case 42: tempOut = (tempIn - 273.15) * 9.0 / 5.0 + 32.0;
  73. printf("\n\n%.2fRø = %.2fgrad F\n\n",tempIn,tempOut);
  74. break;
  75. case 43: tempOut = (tempIn - 273.15) * 9.0 / 5.0 + 32.0;
  76. printf("\n\n%.2fRø = %.2fgrad K\n\n",tempIn,tempOut);
  77. break;
  78. }
  79.  
  80. char skala[50];
  81.  
  82.  
  83. printf("\n--------------------------------------------------");
  84. printf("\n%s", skala);
  85. printf("\n--------------------------------------------------");
  86.  
  87.  
  88. printf("\n\nerneute Berechnung? (j/n)");
  89. scanf("%c",&response);
  90. while (getchar() != '\n');
  91. } while(response == 'j' || response == 'J');
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement