2017-03-24 21:53:41 +01:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
#define Taux 0.21
|
|
|
|
|
|
|
|
|
|
void EncoderDate(int*, int*, int*);
|
|
|
|
|
int DateValide (int, int, int);
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
//Declarer et initialiser les variables
|
|
|
|
|
float PrixU=0;
|
|
|
|
|
float TVA=0;
|
|
|
|
|
int Qte=25;
|
|
|
|
|
float PrixHT=0;
|
|
|
|
|
float PrixTTC=0;
|
|
|
|
|
float PrixTot=0;
|
|
|
|
|
int j=0;
|
|
|
|
|
int m=0;
|
|
|
|
|
int a=0;
|
|
|
|
|
int TorF;
|
|
|
|
|
|
|
|
|
|
//Encoder et v<>rifier la date
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
EncoderDate(&j,&m,&a);
|
|
|
|
|
TorF = DateValide(j, m, a);
|
|
|
|
|
}
|
|
|
|
|
while (TorF == 0);
|
|
|
|
|
|
|
|
|
|
//Encoder le prix et la quantit<69>
|
|
|
|
|
printf("Veuillez entrer le prix a l'unite hors TVA : ");
|
|
|
|
|
scanf("%f", &PrixU);
|
|
|
|
|
printf("Veuillez entrer la quantite desiree : ");
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
scanf("%d", &Qte);
|
|
|
|
|
|
|
|
|
|
//En t<>te de la facture
|
|
|
|
|
printf("La Bulle Informatique\nRoute du Condroz 78, 4123 Neupre\n");
|
|
|
|
|
printf("\nFacture a payer\n");
|
|
|
|
|
|
|
|
|
|
//Calcul des prix
|
|
|
|
|
printf("\nHewlett-Packard ProBook650 : \t%10.2f Euros X%1d\n",PrixU,Qte);
|
|
|
|
|
PrixHT = PrixU*Qte;
|
|
|
|
|
printf("Prix HTVA : \t%10.2f Euros\n",PrixHT);
|
|
|
|
|
TVA = PrixHT*Taux;
|
|
|
|
|
printf("TVA (21%%) : \t%10.2f Euros\n",TVA);
|
|
|
|
|
PrixTTC = PrixHT + TVA;
|
|
|
|
|
printf("\nPrix TTC : \t%10.2f Euros\n",PrixTTC);
|
|
|
|
|
PrixTot = PrixTTC - PrixTTC/10;
|
|
|
|
|
if (Qte>=20)
|
|
|
|
|
{printf("Remise de 10%% a l'achat d'au moins 20 pieces\n");
|
|
|
|
|
printf("Prix total : \t%10.2f Euros\n",PrixTot);
|
|
|
|
|
}
|
|
|
|
|
printf("Date de facturation :");
|
|
|
|
|
if (j<10)
|
|
|
|
|
{
|
|
|
|
|
if (m<10)
|
|
|
|
|
printf("0%d/0%d/%d", j, m, a);
|
|
|
|
|
else
|
|
|
|
|
printf("0%d/%d/%d", j, m, a);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (m<10)
|
|
|
|
|
printf("%d/0%d/%d", j, m, a);
|
|
|
|
|
else
|
|
|
|
|
printf("%d/%d/%d", j, m, a);
|
|
|
|
|
}
|
|
|
|
|
getch();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
void EncoderDate(int *j, int *m, int *a)
|
|
|
|
|
{
|
|
|
|
|
printf("Entrez la date sous cette forme : jj/mm/aaaa\n");
|
|
|
|
|
fflush(stdin); scanf("%d/%d/%d",j,m,a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DateValide(int j, int m, int a)
|
|
|
|
|
{
|
|
|
|
|
int bis;
|
|
|
|
|
if(m != 2)
|
|
|
|
|
{
|
|
|
|
|
if(m >= 1 && m <= 7)
|
|
|
|
|
{
|
|
|
|
|
if(m %2 == 0)
|
|
|
|
|
{
|
|
|
|
|
if(j >= 1 && j <= 30) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(j >= 1 && j <= 31) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(m > 7 && m <= 12)
|
|
|
|
|
{
|
|
|
|
|
if(m %2 == 0)
|
|
|
|
|
{
|
|
|
|
|
if(j >= 1 && j <= 31) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(j >= 1 && j <= 30) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(a %100 == 0)
|
|
|
|
|
{
|
|
|
|
|
if(a %400 == 0) bis = 1;
|
|
|
|
|
else bis = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(a %4 == 0)bis = 1;
|
|
|
|
|
else bis = 0;
|
|
|
|
|
}
|
|
|
|
|
if(bis == 1)
|
|
|
|
|
{
|
|
|
|
|
if(j >= 1 && j <= 29) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(j >= 1 && j <= 28) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|