barnabe0057 icon

TP_Variables_Operations

barnabe0057 | PRO | 02/20/22 05:40:51 PM UTC | 0 ⭐ | 684 👁️ | Never ⏰ | []
C# |

1.37 KB

|

None

|

0 👍

/

0 👎

using System;
 
namespace MNS // Note: actual namespace depends on the project name.
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Niveau 1 Dire Bonjour
            Console.WriteLine("Comment tu t'appelles ?");
            string entree = Console.ReadLine();
 
            Console.WriteLine("Bonjour " + entree);
 
            //Niveau 2 Addition
            Console.WriteLine("Donne moi un nombre : ");
            string nombre1 = Console.ReadLine();
 
            Console.WriteLine("Donne moi un autre nombre : ");
            string nombre2 = Console.ReadLine();
 
            int resultat = int.Parse(nombre1) + int.Parse(nombre2);
 
            Console.WriteLine("La somme de ces deux nombres est : "  + resultat);
            
            //Niveau 3 : Soldes
            Console.WriteLine("Donne moi un prix : ");
            string prix = Console.ReadLine();
 
            Console.WriteLine("Donne moi une pourcentage de réduction : ");
            string reduction = Console.ReadLine();
 
            float prixFloat = float.Parse(prix);
            float reductionFloat = float.Parse(reduction);
 
            float montantRemise = reductionFloat * prixFloat / 100;
            float prixFinal = prixFloat - montantRemise;
 
            Console.WriteLine("Le prix final est : " + prixFinal);
        }
    }
}

Comments