diff --git a/C#.repo b/C#.repo new file mode 100644 index 0000000..e69de29 diff --git a/Program.cs b/Program.cs index 9f3ff5f..1cd022c 100644 --- a/Program.cs +++ b/Program.cs @@ -4,6 +4,86 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello, World!"); + //dichiarazione e inizializzazione variabili + double operatore1, operatore2, risultato; + string scelta, risultatoIntermedio; //risultatoIntermedio serve per gestire la divisione per zero + bool exit; //serve per far uscire il programma senza stampare il risultato + exit=false; + risultatoIntermedio="placeholder"; //inizializzato ad un valore casuale per capire se è stata effettuata la divisione o no + risultato=0; + + //Output iniziale e richiesta dei due numeri su cui fare i calcoli + Console.Write("Inserire il primo numero: "); + operatore1=Convert.ToDouble(Console.ReadLine()); + Console.Write("Inserire il secondo numero: "); + operatore2=Convert.ToDouble(Console.ReadLine()); + Console.WriteLine("Quale operazione eseguire?"); + Console.WriteLine("1. Somma"); + Console.WriteLine("2. Differenza"); + Console.WriteLine("3. Prodotto"); + Console.WriteLine("4. Quoziente"); + Console.WriteLine("0. Esci"); + + do{ + Console.Write("Scelta: "); + scelta=Console.ReadLine(); + switch(scelta){ + case "0": + exit=true; + break; + case "1": + risultato=Somma(operatore1, operatore2); + break; + case "2": + risultato=Differenza(operatore1, operatore2); + break; + case "3": + risultato=Prodotto(operatore1, operatore2); + break; + case "4": + risultatoIntermedio=Quoziente(operatore1, operatore2); + break; + default: + Console.WriteLine("Scelta non valida"); + break; + } + } + while(scelta!="0" && scelta!="1" && scelta!="2" && scelta!="3" && scelta!="4"); //escludo le scelte non valide dal loop + if(exit!=true){//se l'utente non vuole uscire + if (risultatoIntermedio=="error"){ + Console.WriteLine("Impossibile dividere per zero");//gestione della divisione per zero + } + else{ + if(risultatoIntermedio!="placeholder"){//se è stata effettuata una divisione + risultato=Convert.ToDouble(risultatoIntermedio);//assegna il risultato della divisione al risultato double + } + Console.WriteLine("Risultato: " +risultato);//output finale + } + } + } + static double Somma(double operatore1, double operatore2) { + double risultato; + risultato=operatore1+operatore2; + return risultato; + } + static double Differenza(double operatore1, double operatore2) { + double risultato; + risultato=operatore1-operatore2; + return risultato; + } + static double Prodotto(double operatore1, double operatore2) { + double risultato; + risultato=operatore1*operatore2; + return risultato; + } + static string Quoziente(double operatore1, double operatore2) { + string risultato; + if(operatore2==0){//gestione della divisione per zero + return "error"; + } + else{ + risultato=Convert.ToString(operatore1/operatore2); + return risultato; + } } } diff --git a/bin/Debug/net9.0/calcolatrice b/bin/Debug/net9.0/calcolatrice new file mode 100755 index 0000000..2a0ac67 Binary files /dev/null and b/bin/Debug/net9.0/calcolatrice differ diff --git a/bin/Debug/net9.0/calcolatrice.deps.json b/bin/Debug/net9.0/calcolatrice.deps.json new file mode 100644 index 0000000..1ce7336 --- /dev/null +++ b/bin/Debug/net9.0/calcolatrice.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v9.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v9.0": { + "calcolatrice/1.0.0": { + "runtime": { + "calcolatrice.dll": {} + } + } + } + }, + "libraries": { + "calcolatrice/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net9.0/calcolatrice.dll b/bin/Debug/net9.0/calcolatrice.dll new file mode 100644 index 0000000..c42dfe1 Binary files /dev/null and b/bin/Debug/net9.0/calcolatrice.dll differ diff --git a/bin/Debug/net9.0/calcolatrice.pdb b/bin/Debug/net9.0/calcolatrice.pdb new file mode 100644 index 0000000..9f7e8f9 Binary files /dev/null and b/bin/Debug/net9.0/calcolatrice.pdb differ diff --git a/bin/Debug/net9.0/calcolatrice.runtimeconfig.json b/bin/Debug/net9.0/calcolatrice.runtimeconfig.json new file mode 100644 index 0000000..b19c3c8 --- /dev/null +++ b/bin/Debug/net9.0/calcolatrice.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net9.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "9.0.0" + }, + "configProperties": { + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false + } + } +} \ No newline at end of file diff --git a/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs new file mode 100644 index 0000000..9e76325 --- /dev/null +++ b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")] diff --git a/obj/Debug/net9.0/apphost b/obj/Debug/net9.0/apphost new file mode 100755 index 0000000..2a0ac67 Binary files /dev/null and b/obj/Debug/net9.0/apphost differ diff --git a/obj/Debug/net9.0/calcolatrice.AssemblyInfo.cs b/obj/Debug/net9.0/calcolatrice.AssemblyInfo.cs new file mode 100644 index 0000000..84a98d1 --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("calcolatrice")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+81aee42076c07c4c339197485cbd47a851e6dddf")] +[assembly: System.Reflection.AssemblyProductAttribute("calcolatrice")] +[assembly: System.Reflection.AssemblyTitleAttribute("calcolatrice")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generato dalla classe WriteCodeFragment di MSBuild. + diff --git a/obj/Debug/net9.0/calcolatrice.AssemblyInfoInputs.cache b/obj/Debug/net9.0/calcolatrice.AssemblyInfoInputs.cache new file mode 100644 index 0000000..1ecf551 --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +0fa6a2a533d06ae21ae65e08e83ea81139a4541d35132c49b55ca4b3fef5af4c diff --git a/obj/Debug/net9.0/calcolatrice.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net9.0/calcolatrice.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..ee4640c --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,15 @@ +is_global = true +build_property.TargetFramework = net9.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = calcolatrice +build_property.ProjectDir = /home/BrainTheBest5/git/calcolatrice/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.EffectiveAnalysisLevelStyle = 9.0 +build_property.EnableCodeStyleSeverity = diff --git a/obj/Debug/net9.0/calcolatrice.GlobalUsings.g.cs b/obj/Debug/net9.0/calcolatrice.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/obj/Debug/net9.0/calcolatrice.assets.cache b/obj/Debug/net9.0/calcolatrice.assets.cache new file mode 100644 index 0000000..906e977 Binary files /dev/null and b/obj/Debug/net9.0/calcolatrice.assets.cache differ diff --git a/obj/Debug/net9.0/calcolatrice.csproj.CoreCompileInputs.cache b/obj/Debug/net9.0/calcolatrice.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..61383e9 --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +60c8619024e0dede7b06554fddd6bd5bb91b6b74f6c31ceb25355613b71000d7 diff --git a/obj/Debug/net9.0/calcolatrice.csproj.FileListAbsolute.txt b/obj/Debug/net9.0/calcolatrice.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..548c7a9 --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.GeneratedMSBuildEditorConfig.editorconfig +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.AssemblyInfoInputs.cache +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.AssemblyInfo.cs +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.csproj.CoreCompileInputs.cache +/home/BrainTheBest5/git/calcolatrice/bin/Debug/net9.0/calcolatrice +/home/BrainTheBest5/git/calcolatrice/bin/Debug/net9.0/calcolatrice.deps.json +/home/BrainTheBest5/git/calcolatrice/bin/Debug/net9.0/calcolatrice.runtimeconfig.json +/home/BrainTheBest5/git/calcolatrice/bin/Debug/net9.0/calcolatrice.dll +/home/BrainTheBest5/git/calcolatrice/bin/Debug/net9.0/calcolatrice.pdb +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.dll +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/refint/calcolatrice.dll +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.pdb +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/calcolatrice.genruntimeconfig.cache +/home/BrainTheBest5/git/calcolatrice/obj/Debug/net9.0/ref/calcolatrice.dll diff --git a/obj/Debug/net9.0/calcolatrice.dll b/obj/Debug/net9.0/calcolatrice.dll new file mode 100644 index 0000000..c42dfe1 Binary files /dev/null and b/obj/Debug/net9.0/calcolatrice.dll differ diff --git a/obj/Debug/net9.0/calcolatrice.genruntimeconfig.cache b/obj/Debug/net9.0/calcolatrice.genruntimeconfig.cache new file mode 100644 index 0000000..7bdd6e8 --- /dev/null +++ b/obj/Debug/net9.0/calcolatrice.genruntimeconfig.cache @@ -0,0 +1 @@ +a2ffa4f6d06a33e4ef0f6ab8ed9484a6e0703bea5f323c1c744ab773e754a4d5 diff --git a/obj/Debug/net9.0/calcolatrice.pdb b/obj/Debug/net9.0/calcolatrice.pdb new file mode 100644 index 0000000..9f7e8f9 Binary files /dev/null and b/obj/Debug/net9.0/calcolatrice.pdb differ diff --git a/obj/Debug/net9.0/ref/calcolatrice.dll b/obj/Debug/net9.0/ref/calcolatrice.dll new file mode 100644 index 0000000..051a3aa Binary files /dev/null and b/obj/Debug/net9.0/ref/calcolatrice.dll differ diff --git a/obj/Debug/net9.0/refint/calcolatrice.dll b/obj/Debug/net9.0/refint/calcolatrice.dll new file mode 100644 index 0000000..051a3aa Binary files /dev/null and b/obj/Debug/net9.0/refint/calcolatrice.dll differ