Tutti gli elementi funzionano
This commit is contained in:
parent
5092b83b3b
commit
bc3d0a7a31
36
Program.cs
36
Program.cs
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args){ //ci sono eccezioni se viene inserito il nulla ovunque ci sia un Console.ReadLine convertito in altro tipo
|
||||||
{
|
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
//dichiarazione e inizializzazione variabili
|
//dichiarazione e inizializzazione variabili
|
||||||
bool exit=false;
|
bool exit=false;
|
||||||
int scelta;
|
int scelta;
|
||||||
|
string stringa;
|
||||||
|
char punteggiatura;
|
||||||
//menù
|
//menù
|
||||||
do{
|
do{
|
||||||
Console.WriteLine("Scegliere una delle seguenti opzioni:");
|
Console.WriteLine("Scegliere una delle seguenti opzioni:");
|
||||||
@ -29,7 +30,22 @@ class Program
|
|||||||
Convenienza();
|
Convenienza();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
GrepScrauso();
|
//input
|
||||||
|
Console.Write("Inserire una stringa: ");
|
||||||
|
stringa=Console.ReadLine();
|
||||||
|
//output parziale
|
||||||
|
Console.WriteLine("La stringa contiene uno spazio " + GrepScrauso(stringa, ' ') + " volte");
|
||||||
|
Console.WriteLine("La stringa contiene la lettera 'a' " + (GrepScrauso(stringa, 'a')+GrepScrauso(stringa, 'A')) + " volte");//sommo tutte le ricorrenze della a sia maiuscola che minuscola per trovare tutte le ricorrenze della lettera a case insensitive
|
||||||
|
//richiesta segno di punteggiatura
|
||||||
|
Console.WriteLine("Inserire uno tra questi segni di punteggiatura");
|
||||||
|
Console.WriteLine("[?] [!] [:] [;] [.] [,]");
|
||||||
|
Console.Write("Scelta: ");
|
||||||
|
punteggiatura=Convert.ToChar(Console.ReadLine());
|
||||||
|
//output finale
|
||||||
|
Console.WriteLine("La stringa contiene " + punteggiatura + " " + GrepScrauso(stringa, punteggiatura) + " volte");
|
||||||
|
Console.WriteLine("Premere invio per continuare..");
|
||||||
|
Console.ReadLine();
|
||||||
|
Console.Clear();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Scelta non valida");
|
Console.WriteLine("Scelta non valida");
|
||||||
@ -223,4 +239,18 @@ class Program
|
|||||||
static double Scontarello(double p_prezzo, double p_sconto){
|
static double Scontarello(double p_prezzo, double p_sconto){
|
||||||
return p_prezzo-(p_prezzo*p_sconto/100);
|
return p_prezzo-(p_prezzo*p_sconto/100);
|
||||||
}
|
}
|
||||||
|
static int GrepScrauso(string p_stringa, char p_carattere){
|
||||||
|
//dichiarazione e inizializzazione variabili
|
||||||
|
int j=0;
|
||||||
|
|
||||||
|
char[] chars = p_stringa.ToCharArray(); //divido la stringa in una lista di caratteri
|
||||||
|
int lunghezza=chars.Length;//misuro la lunghezza delle righe aka conto quante righe ci sono
|
||||||
|
|
||||||
|
for (int i=0; i<lunghezza; i++){ //per ogni riga della lista
|
||||||
|
if (chars[i] == p_carattere){ //se il carattere p_carattere è presente alla riga i
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("funzioni_2_1")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("funzioni_2_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+c73023b1d1552f0d6e4da40ca3061f8779bfe21a")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5092b83b3b103c7ad4c8eab6a0f3b266aeabe029")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("funzioni_2_1")]
|
[assembly: System.Reflection.AssemblyProductAttribute("funzioni_2_1")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("funzioni_2_1")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("funzioni_2_1")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
49a1109fa5a5d8d3728073479cd22f33878b2a881762e5ee628f6c694088331f
|
51ad1618fa1f79d311cc61a40dd2c6de7ced1ab79646f147c56ba60fa3db87df
|
||||||
|
|||||||
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