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 44 45 46 47 48 49 50 51 52
|
#include<stdio.h>
#define TVA (20./100)
int main (void)
{
printf ("donnez un prix ht :");
fflush (stdout);
{
char s[32];
fgets (s, sizeof s, stdin);
{
double ht = strtod (s, NULL);
double tva = ht * TVA;
double ttc = tva + ht;
double tauxr;
if (ttc < 1001)
{
tauxr = 0;
}
else if (ttc < 2001)
{
tauxr = 1. / 100;
}
else if (ttc < 5001)
{
tauxr = 3. / 100;
}
else
{
tauxr = 5. / 100;
}
{
double remise = ttc * tauxr;
double net = ttc - remise;
#define FMT_S "%-8s"
printf ("\n");
printf (FMT_S " : %10.2f\n", "prix ht", ht);
printf (FMT_S " : %10.2f+\n", "tva", tva);
printf (FMT_S " : %10.2f=\n", "prix ttc", ttc);
printf (FMT_S "(%2.0f%c) : %10.2f-\n", "remise", tauxr * 100, '%', remise);
printf ("\n");
printf (FMT_S " : %10.2f=\n", "net", net);
}
}
}
return 0;
} |
Partager