LePetitGlacon

FICHE 5 BASE Exercice 5

Oct 9th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2.  
  3. namespace p
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Combien de notes ?");
  10.             int nombreNote = int.Parse(Console.ReadLine());
  11.             int compteurNote = 1;
  12.             int noteTotal = 0;
  13.  
  14.             while (compteurNote != nombreNote + 1)
  15.                 {
  16.                
  17.                 Console.WriteLine("Note " + compteurNote);
  18.                 int note = int.Parse(Console.ReadLine());
  19.                
  20.                 if (note < 0 || note > 20)
  21.                 {
  22.                     Console.WriteLine("Cette valeur est fausse");
  23.                 }
  24.                 else
  25.                 {
  26.                     noteTotal = noteTotal + note;
  27.                     compteurNote++;
  28.                 }
  29.              }
  30.             Console.WriteLine("La moyenne est de " + noteTotal / nombreNote);
  31.             Console.ReadKey();
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment