Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int calculerPrix(char categorie, int jour, int age) {
- int prixTicket = -1;
- switch (categorie) {
- case 'a':
- prixTicket = 10;
- break;
- case 'b':
- prixTicket = 20;
- break;
- default:
- return prixTicket;
- }
- if(jour == 2 || jour < 1 || jour > 7) {
- return -1;
- }
- if(jour == 1) {
- prixTicket /= 5;
- } else if(jour == 6 || jour == 7) {
- prixTicket /= 2;
- }
- if(age < 10) {
- prixTicket = 0;
- } else if(age >= 60) {
- prixTicket -= 5;
- }
- return prixTicket;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement