Loading...
Saturday, October 12, 2013

Menghitung Huruf Vokal C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Menghitung_Vokal
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Masukan String: ");
            string input = Console.ReadLine();

            string vokal = "aiueoAIUEO";

            int jumvokal = 0;
            for (int i = 0; i < input.Length; i++)
            {
                for (int a = 0; a < vokal.Length; a++)
                {
                    if (input[i].Equals(vokal[a]))
                    {
                        jumvokal++;
                    }
                }
            }
            Console.WriteLine("Jumlah Vokal: {0}",jumvokal);

            input = input.Trim();
            int jumkata = 1;
            for (int i = 0; i < input.Length; i++)
            {
                if (input.Substring(i,1).Equals(" "))
                {
                    if (!input.Substring(i - 1,1).Equals(" "))
                    {
                        jumkata++;
                    }
                }
            }
            Console.WriteLine("Jumlah Kata {0}", jumkata);
        }
    }
}
Newer Post
Previous
This is the last post.

1 comments:

 
TOP