Allineato con quello che vuole la prof (voglio strapparmi i capelli)
This commit is contained in:
parent
3fc3affa9a
commit
a3934e9e69
58
Program.cs
58
Program.cs
@ -5,10 +5,10 @@ class Program
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint scelta;
|
double celsius=0, fahrenheit=0;
|
||||||
double celsius, fahrenheit, divisore, dividendo;
|
int numero=0, quadrato=0, negativo=0, assoluto=0, divisore=0, dividendo=0, scelta=0;
|
||||||
int numero, quadrato, negativo, assoluto;
|
bool pari=false;
|
||||||
bool exit=false, pari, divisibile;
|
string divisibile="";
|
||||||
|
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
do{
|
do{
|
||||||
@ -20,12 +20,12 @@ class Program
|
|||||||
Console.WriteLine("5. Verifica se un numero è divisibile per un'altro");
|
Console.WriteLine("5. Verifica se un numero è divisibile per un'altro");
|
||||||
Console.WriteLine("6. Esci");
|
Console.WriteLine("6. Esci");
|
||||||
Console.Write("Scelta: ");
|
Console.Write("Scelta: ");
|
||||||
scelta=Convert.ToUInt32(Console.ReadLine());
|
scelta=Convert.ToInt32(Console.ReadLine());
|
||||||
|
|
||||||
switch (scelta){
|
switch (scelta){
|
||||||
case 1:
|
case 1:
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.Write("Inserire la temperatura in gradi: ");
|
Console.Write("Inserire la temperatura: ");
|
||||||
celsius=Convert.ToDouble(Console.ReadLine());
|
celsius=Convert.ToDouble(Console.ReadLine());
|
||||||
fahrenheit=ConvertiCelsiusFahrenheit(celsius);
|
fahrenheit=ConvertiCelsiusFahrenheit(celsius);
|
||||||
Console.WriteLine("La temperatura di " +celsius + "°C corrisponde a " +fahrenheit +"°F");
|
Console.WriteLine("La temperatura di " +celsius + "°C corrisponde a " +fahrenheit +"°F");
|
||||||
@ -72,27 +72,15 @@ class Program
|
|||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.Write("Inserire il dividendo: ");
|
Console.Write("Inserire il dividendo: ");
|
||||||
dividendo=Convert.ToInt32(Console.ReadLine());
|
dividendo=Convert.ToInt32(Console.ReadLine());
|
||||||
do{
|
|
||||||
Console.Write("Inserire il divisore: ");
|
Console.Write("Inserire il divisore: ");
|
||||||
divisore=Convert.ToInt32(Console.ReadLine());
|
divisore=Convert.ToInt32(Console.ReadLine());
|
||||||
if (divisore==0){
|
|
||||||
Console.WriteLine("ERRORE: il divisore deve essere diverso da 0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(divisore==0);
|
|
||||||
divisibile=VerificaDivisibile(dividendo,divisore);
|
divisibile=VerificaDivisibile(dividendo,divisore);
|
||||||
if (divisibile==true){
|
Console.WriteLine(divisibile);
|
||||||
Console.WriteLine("Il primo numero è multiplo del secondo");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Console.WriteLine("Il primo numero non è divisibile per il secondo");
|
|
||||||
}
|
|
||||||
Console.WriteLine("Premere invio per continuare . . .");
|
Console.WriteLine("Premere invio per continuare . . .");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
exit=true;
|
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -103,7 +91,7 @@ class Program
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(exit==false);
|
while(scelta!=6);
|
||||||
}
|
}
|
||||||
static double ConvertiCelsiusFahrenheit(double p_celsius){
|
static double ConvertiCelsiusFahrenheit(double p_celsius){
|
||||||
const double costante1=1.8d;
|
const double costante1=1.8d;
|
||||||
@ -115,27 +103,37 @@ class Program
|
|||||||
}
|
}
|
||||||
static int CalcolaValoreAssoluto(int p_numero){
|
static int CalcolaValoreAssoluto(int p_numero){
|
||||||
const int costante1=-1;
|
const int costante1=-1;
|
||||||
|
int ritorno;
|
||||||
if (p_numero<0){
|
if (p_numero<0){
|
||||||
return p_numero*costante1;
|
ritorno=p_numero*costante1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return p_numero;
|
ritorno=p_numero;
|
||||||
}
|
}
|
||||||
|
return ritorno;
|
||||||
}
|
}
|
||||||
static bool VerificaNumeroPari(int p_numero){
|
static bool VerificaNumeroPari(int p_numero){
|
||||||
if (p_numero%2==0){
|
bool ritorno;
|
||||||
return true;
|
const int costante1=2;
|
||||||
|
if (p_numero%costante1==0){
|
||||||
|
ritorno=true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
ritorno=false;
|
||||||
}
|
}
|
||||||
|
return ritorno;
|
||||||
}
|
}
|
||||||
static bool VerificaDivisibile(double p_dividendo, double p_divisore){
|
static string VerificaDivisibile(int p_dividendo, int p_divisore){
|
||||||
if (p_dividendo%p_divisore==0){
|
string ritorno;
|
||||||
return true;
|
if (p_divisore==0){
|
||||||
|
ritorno="ERRORE: il divisore deve essere diverso da 0";
|
||||||
|
}
|
||||||
|
else if (p_dividendo%p_divisore==0){
|
||||||
|
ritorno="Il primo numero è multiplo del secondo";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
ritorno="Il primo numero non è divisibile per il secondo";
|
||||||
}
|
}
|
||||||
|
return ritorno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("miscellanea")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("miscellanea")]
|
||||||
[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+220aec7cf20cec3f2926987140ddcac87c9681b6")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3fc3affa9a5fe076dfce0a0fcfc9f26f6ec51c34")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("miscellanea")]
|
[assembly: System.Reflection.AssemblyProductAttribute("miscellanea")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("miscellanea")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("miscellanea")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
6bd7e1433996e99ef7f79695f1088081764237b93626276a553bcfeee7056742
|
a22059ea872fcde4de40a7b974b27c911eb5eb21a85bb5a7075d8dce687b16b1
|
||||||
|
|||||||
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