MrDj200

kj zu kcal

Mar 30th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.  
  5.     int choice;
  6.     float faktorKj, faktorKcal, ergebnis, input;
  7.  
  8.     title();
  9.     printf("In welche Einheit wollen Sie umrechnen?\n");
  10.     printf("[1] kJ in kcal\n");
  11.     printf("[2] kcal in kJ\n");
  12.     printf("[3] Programm beenden\n");
  13.     printf("Auswahl: ");
  14.     scanf("%i", &choice);
  15.     fflush(stdin);
  16.  
  17.     faktorKj = 4.184;
  18.     faktorKcal = 0.239006;
  19.  
  20.     if ( choice == 1 ) {
  21.         title();
  22.         printf("Bitte KiloJoule eingeben: ");
  23.         scanf("%f", &input);
  24.         fflush(stdin);
  25.         printf("\n\n");
  26.         ergebnis = input * faktorKcal;
  27.         printf("%.3fkJ sind %.3fkcal\n", input, ergebnis);
  28.         system("pause");
  29.     }
  30.     if ( choice == 2 ) {
  31.         title();
  32.         printf("Bitte Kilokalorien eingeben: ");
  33.         scanf("%f", &input);
  34.         fflush(stdin);
  35.         printf("\n\n");
  36.         ergebnis = input * faktorKj;
  37.         printf("%.3fkcal sind %.3fkJ\n", input, ergebnis);
  38.         system("pause");
  39.     }
  40.     if ( choice == 3 ) {
  41.         system("exit");
  42.     }
  43.  
  44. }
  45.  
  46. int title(){
  47.  
  48.     system("cls");
  49.     system("color 0a");
  50.     system("title Kj zu kcal Rechner");
  51.     printf("####################################\n");
  52.     printf("        Kj zu kcal Rechner\n");
  53.     printf("####################################\n");
  54.     printf("\n");
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment