Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. //---------------------------------------------------------------------------------------------------------------------------
  2. // temp_appel = (nbr_min*60) + nbr_sec //(en secondes)
  3. // nbr_unit = temp_appel/unit //(unit = 20 sec)
  4. // cout_3min = 12,6 DH //(cout_3min = 180/20 * 1,40 = 9*1,40 = 12,6)
  5. // cout_next = nbr_unit * prix_unit + rest_sec //(rest_sec = 0 si: temp_appel%unit=0 , sinon: rest_sec = 1,20)
  6. // cout_appel = cout_3min + cout_next
  7. //---------------------------------------------------------------------------------------------------------------------------
  8. #include<stdio.h>
  9. int main()
  10. {
  11. int nbr_min, nbr_sec, temp_appel, unit=20 ;
  12. float nbr_unit, prix_unit, cout_min, rest_sec, cout_appel ;
  13.  
  14. start:
  15. printf("===========================================================\n");
  16. printf("Calcul du cout d’une communication par appel telephonique\n");
  17. printf("===========================================================\n");
  18. printf("\nEntrez la duree de l'appel (en minutes et secondes):\n");
  19. printf("___________________________________________________________\n");
  20. printf("\n\tMinutes: ");
  21. scanf("%d", &nbr_min);
  22. printf("\tSecondes: ");
  23. scanf("%d", &nbr_sec);
  24. //---------------------------------------------------------------------------------------------------------------------------
  25.  
  26. //---------------------------------------------------------------------------------------------------------------------------
  27. temp_appel = (nbr_min*60)+nbr_sec ;
  28. nbr_unit = temp_appel/unit ;
  29. rest_sec = temp_appel%unit ;
  30. cout_min = (60/unit)*1.40 ;
  31. //---------------------------------------------------------------------------------------------------------------------------
  32. if (temp_appel == 0) { cout_appel = 0; } else
  33. //---------------------------------------------------------------------------------------------------------------------------
  34. if (temp_appel <= 60) {
  35. cout_appel = cout_min ;
  36. } else if (temp_appel <= 180) {
  37. prix_unit = 1.40 ;
  38. if (rest_sec != 0) { rest_sec = prix_unit; }
  39. cout_appel = nbr_unit*prix_unit + rest_sec ;
  40.  
  41. } else {
  42. prix_unit = 1.20 ;
  43. temp_appel = temp_appel - 180 ;
  44. nbr_unit = temp_appel/unit ;
  45. rest_sec = temp_appel%unit ;
  46. if (rest_sec != 0) { rest_sec = prix_unit; };
  47. cout_appel = nbr_unit*prix_unit + rest_sec ;
  48. cout_appel = cout_appel + 3*cout_min ;
  49. }
  50.  
  51. //---------------------------------------------------------------------------------------------------------------------------
  52. printf("___________________________________________________________\n");
  53. printf("\n\tLe cout de l'appel est: %.2f DH\n", cout_appel);
  54. printf("___________________________________________________________\n");
  55. system("pause>nul");
  56. system("cls");
  57. goto start;
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement