1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| program aviation_tassili;
uses crt, sysutils; // sysutils pour la fonction lowercase
var
nom, prenom, destination : string;
age, nb, i : integer;
prix, total : real;
sex : char;
begin
writeln('Welcome');
write('Entrez votre nombre de places => : ');
readln(nb);
total := 0.0;
for i := 1 to nb do begin
write('Entrez le nom n°', i,' => :');
readln(nom);
write('Entrez le prenom => :');
readln(prenom);
repeat
write ('Sexe H/F ? ');
readln(sex);
sex := LowerCase(sex); // Mettre en minuscules
until (sex = 'h') or (sex = 'f') ;
write('Entrez l''age => : ');
readln(age); // Normalement il faudrait vérifier > 0 et < 120
// Destination ?
repeat
write('Entrez la destination ALGER / ANABA => : ');
readln(destination);
destination := UpperCase(destination); // Mettre en majuscules
until (destination = 'ALGER') or (destination = 'ANABA') ;
if destination = 'ALGER' // Prix de base
then prix := 490
else prix := 420;
// Calcul de réduction
if age < 2 then prix := prix*0.70 // Un bébé paye plus cher qu'un ado ?
else if age < 16 then prix := prix*0.30;
if sex = 'h' then write('Monsieur ') else write('Madame ')
writeln(nom, ' ', prenom, ', destination : ', destination, ', prix : ', prix:0:2, ' da');
total := total + prix;
end;
writeln ('La somme totale est de : ', total:0:2, ' da');
writeln ('Merci de votre visite');
end. |
Partager