Sembra tutto ok
This commit is contained in:
parent
5713e73e0f
commit
9a477b26b1
121
Program.cs
121
Program.cs
@ -4,6 +4,125 @@ class Program
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Hello, World!");
|
//dichiarazione e inizializzazione variabile
|
||||||
|
int scelta=9;
|
||||||
|
//Menù
|
||||||
|
Console.WriteLine("Scegliere un'operazione:");
|
||||||
|
Console.WriteLine("1. Calcolo area e perimetro di un quadrato");
|
||||||
|
Console.WriteLine("2. Calcolo sconto di un prezzo");
|
||||||
|
Console.WriteLine("3. Calcolo media");
|
||||||
|
Console.WriteLine("4. Calcolo età");
|
||||||
|
Console.WriteLine("5. Calcolo rette perpendicolari");
|
||||||
|
Console.WriteLine("0. Esci");
|
||||||
|
Console.Write("Scelta: ");
|
||||||
|
scelta=Convert.ToInt32(Console.ReadLine());
|
||||||
|
|
||||||
|
|
||||||
|
do{
|
||||||
|
switch(scelta){
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
//dichiarazione e inizializzazione variabili
|
||||||
|
double lato, area, perimetro;
|
||||||
|
//ricevo input
|
||||||
|
Console.Write("Inserire il lato: ");
|
||||||
|
lato=Convert.ToDouble(Console.ReadLine());
|
||||||
|
//chiamo funzioni per i calcoli
|
||||||
|
area=Area(lato);
|
||||||
|
perimetro=Perimetro(lato);
|
||||||
|
//output
|
||||||
|
Console.WriteLine("Il perimtetro è " +perimetro +" mentre l'area è " +area);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//dichiarazione e inizializzazione variabili
|
||||||
|
double prezzo, sconto;
|
||||||
|
//ricevo input
|
||||||
|
Console.Write("Inserire il prezzo: ");
|
||||||
|
prezzo=Convert.ToDouble(Console.ReadLine());
|
||||||
|
Console.Write("Inserire la percentuale di sconto (senza %): ");
|
||||||
|
sconto=Convert.ToDouble(Console.ReadLine());
|
||||||
|
//output con chiamata a funzione per il calcolo integrata
|
||||||
|
Console.WriteLine("Il prezzo scontato è " +Scontatore(prezzo, sconto));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
//dichiarazione e inizializzazione variabili
|
||||||
|
double somma, numeroVero;
|
||||||
|
string numero;
|
||||||
|
int i;
|
||||||
|
somma=0;
|
||||||
|
i=0;
|
||||||
|
//ricevo input di continuo
|
||||||
|
do{
|
||||||
|
//ricevo input
|
||||||
|
Console.Write("Inserire un numero ([q] per terminare): ");
|
||||||
|
numero=Console.ReadLine();
|
||||||
|
//verifico se non si vuole terminare
|
||||||
|
if(numero!="q"){
|
||||||
|
numeroVero=Convert.ToDouble(numero);//non so come fare una condizione che verifichi se Convert.ToDouble abbia restituito un'eccezione aka è stata inserito un qualcosa che non sia un numero o q
|
||||||
|
somma=somma+numeroVero;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(numero!="q");
|
||||||
|
//output
|
||||||
|
Console.WriteLine("La media è " +Media(somma, i));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
int anno, nascita;
|
||||||
|
Console.Write("Che anno è? ");
|
||||||
|
anno=Convert.ToInt32(Console.ReadLine());
|
||||||
|
Console.Write("Quando sei nato? ");
|
||||||
|
nascita=Convert.ToInt32(Console.ReadLine());
|
||||||
|
Console.WriteLine("Hai " +Età(anno, nascita) +" anni");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
double coefficiente, intercetta;
|
||||||
|
Console.Write("Inserire il coefficiente angolare: ");
|
||||||
|
coefficiente=Convert.ToDouble(Console.ReadLine());
|
||||||
|
Console.Write("Inserire l'intercetta: ");
|
||||||
|
intercetta=Convert.ToDouble(Console.ReadLine());
|
||||||
|
if(IsPerpendicolare(coefficiente, intercetta)==true){
|
||||||
|
Console.WriteLine("Le due rette sono perpendicolari");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Console.WriteLine("Le due rette non sono perpendicolari");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Scelta non valida");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(scelta!=0 && scelta!=1 && scelta!=2 && scelta!=3 && scelta!=4 && scelta!=5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double Area(double p_lato){
|
||||||
|
return p_lato*p_lato;
|
||||||
|
}
|
||||||
|
static double Perimetro(double p_lato){
|
||||||
|
return p_lato*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double Scontatore(double p_prezzo, double p_sconto){ //Scontatore è da intendersi come "colui che applica lo sconto" (lo so che non è italiano ma mi stava simpatico come nome)
|
||||||
|
return p_prezzo-(p_prezzo*p_sconto/100);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double Media(double p_somma, int p_i){
|
||||||
|
return p_somma/p_i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Età(int p_anno, int p_nascita){
|
||||||
|
return p_anno-p_nascita;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsPerpendicolare(double p_coefficiente, double p_intercetta){
|
||||||
|
|
||||||
|
if (p_coefficiente*p_intercetta==-1){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
bin/Debug/net9.0/funzioni_2
Executable file
BIN
bin/Debug/net9.0/funzioni_2
Executable file
Binary file not shown.
23
bin/Debug/net9.0/funzioni_2.deps.json
Normal file
23
bin/Debug/net9.0/funzioni_2.deps.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"runtimeTarget": {
|
||||||
|
"name": ".NETCoreApp,Version=v9.0",
|
||||||
|
"signature": ""
|
||||||
|
},
|
||||||
|
"compilationOptions": {},
|
||||||
|
"targets": {
|
||||||
|
".NETCoreApp,Version=v9.0": {
|
||||||
|
"funzioni_2/1.0.0": {
|
||||||
|
"runtime": {
|
||||||
|
"funzioni_2.dll": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"funzioni_2/1.0.0": {
|
||||||
|
"type": "project",
|
||||||
|
"serviceable": false,
|
||||||
|
"sha512": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
bin/Debug/net9.0/funzioni_2.dll
Normal file
BIN
bin/Debug/net9.0/funzioni_2.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/funzioni_2.pdb
Normal file
BIN
bin/Debug/net9.0/funzioni_2.pdb
Normal file
Binary file not shown.
12
bin/Debug/net9.0/funzioni_2.runtimeconfig.json
Normal file
12
bin/Debug/net9.0/funzioni_2.runtimeconfig.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"runtimeOptions": {
|
||||||
|
"tfm": "net9.0",
|
||||||
|
"framework": {
|
||||||
|
"name": "Microsoft.NETCore.App",
|
||||||
|
"version": "9.0.0"
|
||||||
|
},
|
||||||
|
"configProperties": {
|
||||||
|
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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
BIN
obj/Debug/net9.0/apphost
Executable file
Binary file not shown.
22
obj/Debug/net9.0/funzioni_2.AssemblyInfo.cs
Normal file
22
obj/Debug/net9.0/funzioni_2.AssemblyInfo.cs
Normal 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("funzioni_2")]
|
||||||
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5713e73e0f4bf87c7192ef8a76c71cab23ee0b71")]
|
||||||
|
[assembly: System.Reflection.AssemblyProductAttribute("funzioni_2")]
|
||||||
|
[assembly: System.Reflection.AssemblyTitleAttribute("funzioni_2")]
|
||||||
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
|
// Generato dalla classe WriteCodeFragment di MSBuild.
|
||||||
|
|
||||||
1
obj/Debug/net9.0/funzioni_2.AssemblyInfoInputs.cache
Normal file
1
obj/Debug/net9.0/funzioni_2.AssemblyInfoInputs.cache
Normal file
@ -0,0 +1 @@
|
|||||||
|
6b63cadddfc682d63f46affe7872bb872920c20a5c76387da40259c0b6bd9482
|
||||||
@ -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 = funzioni_2
|
||||||
|
build_property.ProjectDir = /home/BrainTheBest5/git/funzioni_2/
|
||||||
|
build_property.EnableComHosting =
|
||||||
|
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||||
|
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||||
|
build_property.EnableCodeStyleSeverity =
|
||||||
8
obj/Debug/net9.0/funzioni_2.GlobalUsings.g.cs
Normal file
8
obj/Debug/net9.0/funzioni_2.GlobalUsings.g.cs
Normal 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;
|
||||||
BIN
obj/Debug/net9.0/funzioni_2.assets.cache
Normal file
BIN
obj/Debug/net9.0/funzioni_2.assets.cache
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
8e3c979c6b7c07b6081ed1714b4b701ec12345eefac30d1d0672f7216f26f261
|
||||||
14
obj/Debug/net9.0/funzioni_2.csproj.FileListAbsolute.txt
Normal file
14
obj/Debug/net9.0/funzioni_2.csproj.FileListAbsolute.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/home/BrainTheBest5/git/funzioni_2/bin/Debug/net9.0/funzioni_2
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/bin/Debug/net9.0/funzioni_2.deps.json
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/bin/Debug/net9.0/funzioni_2.runtimeconfig.json
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/bin/Debug/net9.0/funzioni_2.dll
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/bin/Debug/net9.0/funzioni_2.pdb
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.GeneratedMSBuildEditorConfig.editorconfig
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.AssemblyInfoInputs.cache
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.AssemblyInfo.cs
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.csproj.CoreCompileInputs.cache
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.dll
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/refint/funzioni_2.dll
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.pdb
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/funzioni_2.genruntimeconfig.cache
|
||||||
|
/home/BrainTheBest5/git/funzioni_2/obj/Debug/net9.0/ref/funzioni_2.dll
|
||||||
BIN
obj/Debug/net9.0/funzioni_2.dll
Normal file
BIN
obj/Debug/net9.0/funzioni_2.dll
Normal file
Binary file not shown.
1
obj/Debug/net9.0/funzioni_2.genruntimeconfig.cache
Normal file
1
obj/Debug/net9.0/funzioni_2.genruntimeconfig.cache
Normal file
@ -0,0 +1 @@
|
|||||||
|
f624f9bd354842a7ee680a418e301e05b114da1ddb5fe33191943e19d3903a33
|
||||||
BIN
obj/Debug/net9.0/funzioni_2.pdb
Normal file
BIN
obj/Debug/net9.0/funzioni_2.pdb
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/ref/funzioni_2.dll
Normal file
BIN
obj/Debug/net9.0/ref/funzioni_2.dll
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/refint/funzioni_2.dll
Normal file
BIN
obj/Debug/net9.0/refint/funzioni_2.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user