Sembra essere funzionante

This commit is contained in:
La Programmatrice Verde
2024-11-19 13:14:07 +01:00
parent 81aee42076
commit 1759e6dafc
21 changed files with 182 additions and 1 deletions

0
C#.repo Normal file
View File

View File

@@ -4,6 +4,86 @@ class Program
{ {
static void Main(string[] args) 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;
}
} }
} }

BIN
bin/Debug/net9.0/calcolatrice Executable file

Binary file not shown.

View File

@@ -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": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

BIN
obj/Debug/net9.0/apphost Executable file

Binary file not shown.

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
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.

View File

@@ -0,0 +1 @@
0fa6a2a533d06ae21ae65e08e83ea81139a4541d35132c49b55ca4b3fef5af4c

View File

@@ -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 =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
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;

Binary file not shown.

View File

@@ -0,0 +1 @@
60c8619024e0dede7b06554fddd6bd5bb91b6b74f6c31ceb25355613b71000d7

View File

@@ -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

Binary file not shown.

View File

@@ -0,0 +1 @@
a2ffa4f6d06a33e4ef0f6ab8ed9484a6e0703bea5f323c1c744ab773e754a4d5

Binary file not shown.

Binary file not shown.

Binary file not shown.