Advertisement
Guest User

ex4

a guest
Oct 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package Isn;
  2.  
  3. public class ex4 {
  4. public static void main (String[]args) {
  5. {
  6. System.out.print("type de lettre (0=verte, 1=prioritaire, 2=ecopli) :");
  7. int typeLettre = Integer.parseInt(System.console().readLine());
  8. System.out.print("Poids :");
  9. float poids = Float.parseFloat(System.console().readLine());
  10.  
  11. System.console.printLn(prix(typeLettre,poids));
  12. }
  13. }
  14.  
  15. int prix(int type, float poids)
  16. {
  17. if(poids <= 20)
  18. {
  19. if(type == 0)
  20. {
  21. return 0.57;
  22. }
  23. else if(type==1)
  24. {
  25. return 0.6;
  26. }
  27. else if(type==2)
  28. {
  29. return 0.55;
  30. }
  31. }
  32. else if(poids > 20 && poids <= 50)
  33. {
  34. if(type == 0)
  35. {
  36. return 0.95;
  37. }
  38. else if(type==1)
  39. {
  40. return 1.0;
  41. }
  42. else if(type==2)
  43. {
  44. return 0.78;
  45. }
  46. }
  47. else if(poids <= 100)
  48. {
  49. if(type == 0)
  50. {
  51. return 1.4;
  52. }
  53. else if(type==1)
  54. {
  55. return 1.45;
  56. }
  57. else if(type==2)
  58. {
  59. return 1.0;
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement