Eccezioni concluse
This commit is contained in:
parent
16f1dea942
commit
83df6fb174
17
Program.cs
17
Program.cs
@ -3,9 +3,9 @@
|
|||||||
class Program {
|
class Program {
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
int scelta = 0;
|
int scelta = 0;
|
||||||
double input = 0;
|
int input = 0;
|
||||||
bool eccezione;
|
bool eccezione;
|
||||||
int[] array = null;
|
int[] array;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class Program {
|
|||||||
Console.Write("Inserire un numero: ");
|
Console.Write("Inserire un numero: ");
|
||||||
eccezione = false;
|
eccezione = false;
|
||||||
try {
|
try {
|
||||||
input = Convert.ToDouble(Console.ReadLine());
|
input = Convert.ToInt32(Console.ReadLine());
|
||||||
}
|
}
|
||||||
catch (FormatException) {
|
catch (FormatException) {
|
||||||
Console.WriteLine("Numero non valido");
|
Console.WriteLine("Numero non valido");
|
||||||
@ -87,19 +87,21 @@ class Program {
|
|||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
static double Divisione(double input) {
|
static double Divisione(int input) {
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
bool eccezione;
|
bool eccezione;
|
||||||
double ritorno = 0;
|
double ritorno;
|
||||||
do {
|
do {
|
||||||
|
int numero = r.Next(0, 4);
|
||||||
eccezione = false;
|
eccezione = false;
|
||||||
try {
|
try {
|
||||||
ritorno = input / r.Next(0, 4);
|
ritorno = input / numero;
|
||||||
}
|
}
|
||||||
catch (DivideByZeroException) {
|
catch (DivideByZeroException) {
|
||||||
Console.WriteLine("Impossibile dividere per 0.");
|
Console.WriteLine("Impossibile dividere per 0.");
|
||||||
Pausa();
|
Pausa();
|
||||||
eccezione = true;
|
eccezione = true;
|
||||||
|
ritorno = double.NaN;
|
||||||
}
|
}
|
||||||
} while (eccezione);
|
} while (eccezione);
|
||||||
return ritorno;
|
return ritorno;
|
||||||
@ -132,6 +134,9 @@ class Program {
|
|||||||
Pausa();
|
Pausa();
|
||||||
eccezione = true;
|
eccezione = true;
|
||||||
}
|
}
|
||||||
|
catch (IndexOutOfRangeException e) {
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (eccezione);
|
while (eccezione);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("eccezioni_1")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("eccezioni_1")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0dc3eed65f04928e028a1afc17f4bc8f367f78bd")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+16f1dea94221582c4d8b3ad11e57771f328fe1eb")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("eccezioni_1")]
|
[assembly: System.Reflection.AssemblyProductAttribute("eccezioni_1")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("eccezioni_1")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("eccezioni_1")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
ee7e98605e9c5564468cd86c1b1c002f51995b579fee2b845d8a36b5f951a60b
|
48a3fed5e6086b9afebbe353b2777958bf4a496d106ab6a3b2c1f2232e423364
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user