You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.0 KiB

#include "tp4.h"
// Location du logement //
int saisirLogement(char *type, int *nbPers, char *pension)
{
printf("Quel logement voulez vous ? (A, B) :");
scanf("%c%*c", type);
printf("nb de Pers :");
scanf("%d%*c", nbPers);
if(*type == 'B')
{
printf("Quel pension avez vous ? (C, D) :");
scanf("%c%*c", pension);
}
if(*type == 'A')
{
if(*nbPers > 6)
{
printf("pb : nb de personnes non cohérent, location refusé.\n");
return 1;
}
}
return 0;
}
float coutLogement (char type, int nbPers, char pension)
{
float prix;
int nbChambres;
if(type == 'A' || type == 'a')
if(nbPers <= 4)
prix = 800;
else prix = 800 + (nbPers-4)*((800*10.0)/100);
else
{
nbChambres = nbPers/3;
if(nbPers % 3 != 0)
nbChambres = nbChambres + 1;
prix = nbChambres * 230;
if(pension == 'd' || pension == 'D')
prix = prix + 120 * nbPers;
else prix = prix + 210 * nbPers;
return prix;
}
}
// Activité ski //
int saisirActiviteSki(int *nbPers, int *nbPack, int *nbSki)
{
char rep;
printf("Nombre de personnes ayant choisie l'activité ski :");
scanf("%d%*c", nbPers);
printf("Voulez vous du matos ??? (O, N) :");
scanf("%c%*c", &rep);
if(rep == 'O' || rep == 'o')
{
printf("Nb de pack ski : ");
scanf("%d%*c", nbPack);
printf("Nombre de ski seuls :");
scanf("%d%*c", nbSki);
if((*nbPack + *nbSki) > *nbPers)
{
printf("pb : nombre de personnes et de matériels non cohérents, activité non validée.\n");
return 1;
}
}
else
{
*nbPack = 0;
*nbSki = 0;
}
return 0;
}
float coutActiviteSki(int nbPers, int nbPack, int nbSki, float *reduc)
{
float forfaitPistes, prixLocMateriel, totalMateriel, coutActiviteSkiSansReduction;
forfaitPistes = nbPers * 150;
coutActiviteSkiSansReduction = forfaitPistes + nbPack*120 + nbSki*80;
totalMateriel = nbPack + nbSki;
if(totalMateriel <= 3)
*reduc = 0;
else
if(nbPack <= 3)
*reduc = (totalMateriel - 3)*80*(50.0/100);
else *reduc = ((nbPack-3)*120 + nbSki * 80) * (50.0/100);
return coutActiviteSkiSansReduction;
}
// fonction totale //
void globale (void)
{
int nbPers, nbPack, nbSki, resultat;
float reduc, prix;
float prixS, prix, prixTot;
char Ski;
printf("Voulez vous faire du ski (O, N) :")
scanf("%c%*c", &Ski);
saisirLogement();
if()
prix = coutLogement(type, nbPers, pension);
if(Ski == 'O' || Ski == 'o');
{
saisirActiviteSki();
prixS = coutActiviteSki(in nbPers, int nbPack, int nbSki);
prixSR = prixS - reduc;
prixTot = prix + (prixS - reduc);
printf("Coût logement : %.2f\n Côut activité ski : %.2f\n Montant reduction ski : %.2f\n Total : %.2f\n", prix, prixS, reduc, prixTot);
}
else
printf("Total : %.2f\n", prixTot);
}