using System;
using System.Collections.Generic;
using System.Text;
/*Desarrollar un programa en C# para capturar una frase entre una y 10 palabras para luego determinar
* e imprimir lo siguiente:
* # de letras vocales total en la frase
* # de consonantes total en la frase
* # de vocales A,a,á en la frase
* # de vocales E,e,é en la frase
* # de vocales I,i,í en la frase
* # de vocales O,o,ó en la frase
* # de vocales U,u,ú en la frase
* # de caracteres no vocales, ni consonantes total en la frase
* # de palabras que inician con letra mayusculas en la frase.
* */
namespace parcial_4
{
class Program
{
static void Main(string[] args)
{
int I, Pal, B = 0, Esp, Caract, conta = 0, conte = 0, conti = 0, conto = 0, contu = 0, conts = 0, a = 0;
string F="";
Console.Write("\n\nPrograma que analiza una frase ingresada\n\n");
do
{
Console.Write("Ingrese la frase: ");
F = Console.ReadLine();
a = F.Length;
while (a == 0)
{
Console.WriteLine("\n No introdujo ninguna frase, ");
Console.Write("Ingrese la frase: ");
F = Console.ReadLine();
a = F.Length;
}
char[] aux = F.ToCharArray();
Esp = 0;
Pal = 0;
I = 0;
Caract = 0;
while ((I != F.Length) && (Esp < 2))
{
if (aux[I] == ' ')
{
if (B == 1)
{
Pal = Pal + 1;
B = 0;
}
Esp = Esp + 1;
}
else
{
B = 1;
Esp = 0;
Caract++;
}
I++;
}
if ((I == F.Length) && (aux[I - 1] != ' '))
{
Pal++;
}
if (Esp > 1)
{
Console.WriteLine("\n Introdujo una frase con dos o mas espacios juntos, ");
Console.WriteLine("tendrá que ingresar la frase nuevamente.\n");
}
if (Pal > 10)
{
Console.WriteLine("\nIntrodujo una frase con una cantidad de palabras inválida, ");
Console.WriteLine("\n Ingrese otra frase.\n");
}
}
while (Esp > 1 || Pal > 10);
Console.Write("\n La frase original es: ");
Console.Write("\n" + F + "\n");
Console.WriteLine("\nCantidad de Palabras: " + Pal);
Console.WriteLine();
string[] Frase = F.Split(new char[] { ' ' });
int mayu = 0, contc = 0;
I = 0;
foreach (string Palabra in Frase)
{
bool x;
char[] arreglo = Palabra.ToCharArray();
int con;
con = arreglo.Length;
x = char.IsUpper(arreglo[0]);
if (x == true)
{
mayu = mayu + 1;
}
for (I = 0; I < con; I++)
{
if ((arreglo[I] == 'A') || (arreglo[I] == 'a') || (arreglo[I] == 'á'))
{
conta = conta + 1;
}
else
{
if ((arreglo[I] == 'E') || (arreglo[I] == 'e') || (arreglo[I] == 'é'))
{
conte = conte + 1;
}
else
{
if ((arreglo[I] == 'I') || (arreglo[I] == 'i') || (arreglo[I] == 'í'))
{
conti = conti + 1;
}
else
{
if ((arreglo[I] == 'O') || (arreglo[I] == 'o') || (arreglo[I] == 'ó'))
{
conto = conto + 1;
}
else
{
if ((arreglo[I] == 'U') || (arreglo[I] == 'u') || (arreglo[I] == 'ú'))
{
contu = contu + 1;
}
else
{
if ((arreglo[I] == 'B') || (arreglo[I] == 'b') || (arreglo[I] == 'C') || (arreglo[I] == 'c') || (arreglo[I] == 'D') || (arreglo[I] == 'd') || (arreglo[I] == 'F') || (arreglo[I] == 'f') || (arreglo[I] == 'G') || (arreglo[I] == 'g') || (arreglo[I] == 'H') || (arreglo[I] == 'h') || (arreglo[I] == 'J') || (arreglo[I] == 'j') || (arreglo[I] == 'K') || (arreglo[I] == 'k') || (arreglo[I] == 'L') || (arreglo[I] == 'l') || (arreglo[I] == 'M') || (arreglo[I] == 'm') || (arreglo[I] == 'N') || (arreglo[I] == 'n') || (arreglo[I] == 'Ñ') || (arreglo[I] == 'ñ') || (arreglo[I] == 'P') || (arreglo[I] == 'p') || (arreglo[I] == 'Q') || (arreglo[I] == 'q') || (arreglo[I] == 'R') || (arreglo[I] == 'r') || (arreglo[I] == 'S') || (arreglo[I] == 's') || (arreglo[I] == 'T') || (arreglo[I] == 't') || (arreglo[I] == 'V') || (arreglo[I] == 'v') || (arreglo[I] == 'W') || (arreglo[I] == 'w') || (arreglo[I] == 'X') || (arreglo[I] == 'x') || (arreglo[I] == 'Y') || (arreglo[I] == 'y') || (arreglo[I] == 'Z') || (arreglo[I] == 'z'))
{
contc = contc + 1;
}
else
{
conts = conts + 1;
}
}
}
}
}
}
}
}
Console.WriteLine("Cantidad de Vocales A,a,á = " + conta);
Console.WriteLine("Cantidad de Vocales E,e,é = " + conte);
Console.WriteLine("Cantidad de Vocales I,i,í = " + conti);
Console.WriteLine("Cantidad de Vocales O,o,ó = " + conto);
Console.WriteLine("Cantidad de Vocales U,u,ú = " + contu);
Console.WriteLine("Cantidad de Consonantes =" + contc);
Console.WriteLine("Cantidad de caracteres que no son consonantes ni vocales =" + conts);
int totalv = 0;
totalv = conta + conte + conti + conto + contu;
Console.WriteLine("Cantidad Total de Vocales =" + totalv);
Console.WriteLine("Cantidad de Palabras que empiezan con mayuscula=" + mayu);
Console.ReadLine();
}
}
}