LePetitGlacon

FICHE 5 ++ Exercice 2

Oct 21st, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2.  
  3. namespace o
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             float fixe = 2000f;
  10.             string fini = "";
  11.             float Km;
  12.             float salaire = 0;
  13.             float ssalaire;
  14.             string Topnom = "";
  15.             float Topsalaire = 0;
  16.  
  17.            
  18.            
  19.             while (fini != "N")
  20.             {
  21.                 Console.WriteLine("Quel est votre nom ?");
  22.                 string nom = Console.ReadLine();
  23.                 Console.WriteLine("Quel région ?\n\nParis et banlieu\t[1]\nNord\t\t\t[2]\nSud\t\t\t[3]");
  24.                 int region = int.Parse(Console.ReadLine());
  25.                 Console.WriteLine("Quel est le nombre de km parcouru ?");
  26.                 float nbKm = float.Parse(Console.ReadLine());
  27.  
  28.                 ssalaire = salaire;
  29.                 if (region == 2 || region == 3)
  30.                 {
  31.                     Km = 0.80f;
  32.                 }
  33.                 else
  34.                 {
  35.                     Km = 1.05f;
  36.                 }
  37.                 salaire = (Km * nbKm) + fixe;
  38.                 Console.WriteLine("Votre salaire est de {0} euros",salaire);
  39.  
  40.  
  41.                 if (salaire > ssalaire)
  42.                 {
  43.                     Console.WriteLine("\nTop Salaire {0} de {1}\n", salaire, nom);
  44.                     Topnom = nom;
  45.                     Topsalaire = salaire;
  46.                 }
  47.                 else
  48.                 {
  49.                     Console.WriteLine("\nTop Salaire {0} de {1}\n", Topsalaire, Topnom);
  50.                 }
  51.  
  52.                 Console.WriteLine("Encore un employé ? [O]\nPour arrêter [N]");
  53.                 fini = Console.ReadLine();
  54.             }
  55.  
  56.            
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment