C#:Réponses aux exercices 4
C#:Réponses aux exercices 4Solutions Exercice instruction While 001Enoncé
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace exerciceInstructionWhile001
{
class Program
{
static void Main(string[] args)
{
double note, moyenne,somme=0;
int nbr_note=1;
char sortie;
do
{
System.Console.WriteLine("Voulez vous saisir la note numéro :" + nbr_note);
sortie = Convert.ToChar(Console.ReadLine());
if(sortie == 'o')
{
System.Console.WriteLine("Saisir la note numéro :" + nbr_note);
note = Convert.ToDouble(Console.ReadLine());
if(note>=0 && note<=20)
{
somme +=note;
nbr_note++;
}
else
{
System.Console.WriteLine("La note doit être entre 0 et 20");
}
}
}
while (sortie == 'o');
moyenne = somme / (nbr_note-1);
System.Console.WriteLine("La nbr note est :"+ (nbr_note-1));
System.Console.WriteLine("La somme est :"+ somme);
System.Console.WriteLine("La moyenne est :"+ moyenne);
}
}
}
|
