Advertisement
iSach

Untitled

Feb 24th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public int calculerPrix(char categorie, int jour, int age) {
  2. int prixTicket = -1;
  3.  
  4. switch (categorie) {
  5. case 'a':
  6. prixTicket = 10;
  7. break;
  8. case 'b':
  9. prixTicket = 20;
  10. break;
  11. default:
  12. return prixTicket;
  13. }
  14.  
  15. if(jour == 2 || jour < 1 || jour > 7) {
  16. return -1;
  17. }
  18.  
  19. if(jour == 1) {
  20. prixTicket /= 5;
  21. } else if(jour == 6 || jour == 7) {
  22. prixTicket /= 2;
  23. }
  24.  
  25. if(age < 10) {
  26. prixTicket = 0;
  27. } else if(age >= 60) {
  28. prixTicket -= 5;
  29. }
  30.  
  31. return prixTicket;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement