-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExBoucles6.cs
32 lines (30 loc) · 868 Bytes
/
ExBoucles6.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Logique;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace exercices
{
public class ExBoucles6 : iCommand
{
public string Name => "06_ExBoucles";
public void Execute()
{
double nb,r;
Console.Write("Tu veux calculer la racine carrée de quel nombre ? ");
bool b = double.TryParse(Console.ReadLine(), out nb);
string nombreAvecDecimale;
r = Math.Sqrt(nb);
if (r % 1 == 0)
{
nombreAvecDecimale = r.ToString("0");
}
else
{
nombreAvecDecimale = r.ToString("0.##########");
}
Console.WriteLine($"La racine carrée de {nb} est égale à {nombreAvecDecimale}.");
}
}
}