Adloun

HTML : structurer le Web (école d'ingénieur) · Chapitre 5 · Exercice de TD

Valeur du stock

Tableaux de données · niveau 2

Énoncé

Reprendre le catalogue de la librairie et lui ajouter une colonne « Valeur » (prix × stock pour chaque livre), puis un pied de tableau donnant le nombre total d'exemplaires et la valeur totale du stock. Calculer ces valeurs.

Corrigé

Valeurs : ; ; ; ; ; . Total des exemplaires : ; valeur totale : €. Le pied fusionne « Titre » et « Prix » pour son intitulé, puis donne les deux totaux.


<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="utf-8">
  <title>Valeur du stock</title>
</head>
<body>
  <table>
    <caption>Valeur du stock de la Librairie du Campus</caption>
    <thead>
      <tr>
        <th scope="col">Titre</th>
        <th scope="col">Prix</th>
        <th scope="col">Stock</th>
        <th scope="col">Valeur</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">Introduction à l'algorithmique</th>
        <td>89,00 €</td><td>4</td><td>356,00 €</td>
      </tr>
      <tr>
        <th scope="row">Programmation Java</th>
        <td>32,00 €</td><td>12</td><td>384,00 €</td>
      </tr>
      <tr>
        <th scope="row">Le Petit Prince</th>
        <td>8,50 €</td><td>25</td><td>212,50 €</td>
      </tr>
      <tr>
        <th scope="row">Analyse MPSI</th>
        <td>45,00 €</td><td>0</td><td>0,00 €</td>
      </tr>
      <tr>
        <th scope="row">L'Étranger</th>
        <td>7,90 €</td><td>18</td><td>142,20 €</td>
      </tr>
      <tr>
        <th scope="row">Physique générale</th>
        <td>59,00 €</td><td>3</td><td>177,00 €</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th scope="row" colspan="2">Total</th>
        <td>62</td>
        <td>1 271,70 €</td>
      </tr>
    </tfoot>
  </table>
</body>
</html>

Dans le livre JavaScript, ces totaux seront calculés par le navigateur ; ici, ils sont écrits à la main.

100 % gratuit

La suite du chapitre est sur Adloun

Exercice suivant et tuteur

Sans compte : le cours et le premier QCM. Exercices et tuteur : inscription gratuite en 30 secondes, sans carte bancaire.

Le cours du chapitre · Tous les exercices du chapitre

Exercice suivant et tuteur →