barnabe0057

TP_Variables_Operations

Feb 20th, 2022
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MNS // Note: actual namespace depends on the project name.
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //Niveau 1 Dire Bonjour
  10.             Console.WriteLine("Comment tu t'appelles ?");
  11.             string entree = Console.ReadLine();
  12.  
  13.             Console.WriteLine("Bonjour " + entree);
  14.  
  15.             //Niveau 2 Addition
  16.             Console.WriteLine("Donne moi un nombre : ");
  17.             string nombre1 = Console.ReadLine();
  18.  
  19.             Console.WriteLine("Donne moi un autre nombre : ");
  20.             string nombre2 = Console.ReadLine();
  21.  
  22.             int resultat = int.Parse(nombre1) + int.Parse(nombre2);
  23.  
  24.             Console.WriteLine("La somme de ces deux nombres est : "  + resultat);
  25.            
  26.             //Niveau 3 : Soldes
  27.             Console.WriteLine("Donne moi un prix : ");
  28.             string prix = Console.ReadLine();
  29.  
  30.             Console.WriteLine("Donne moi une pourcentage de rΓ©duction : ");
  31.             string reduction = Console.ReadLine();
  32.  
  33.             float prixFloat = float.Parse(prix);
  34.             float reductionFloat = float.Parse(reduction);
  35.  
  36.             float montantRemise = reductionFloat * prixFloat / 100;
  37.             float prixFinal = prixFloat - montantRemise;
  38.  
  39.             Console.WriteLine("Le prix final est : " + prixFinal);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment