#include <iostream>
#include <string>
using namespace std;
string nama;
int pilihan, count;
void reverse(string nama)
{
for(int i=nama.length();i>=0;i--)
{
if(nama[i]=='a')
{
nama[i]='A';
}
cout<<nama[i];
}
}
void hitungaiueo(string nama)
{
count=0;
for(int j=0;j<nama.length();j++)
{
if(nama[j]=='a' || nama[j]=='A' || nama[j]=='i' || nama[j]=='I' ||
nama[j]=='u' || nama[j]=='U' || nama[j]=='e' || nama[j]=='E' ||
nama[j]=='o' || nama[j]=='O')
{
count=count+1;
}
}
cout<<"Jumlah vocal character : "<<count;
}
void hitungkonsonan(string nama)
{
count=0;
for(int j=0;j<nama.length();j++)
{
if(nama[j]=='a' || nama[j]=='A' || nama[j]=='i' || nama[j]=='I' ||
nama[j]=='u' || nama[j]=='U' || nama[j]=='e' || nama[j]=='E' ||
nama[j]=='o' || nama[j]=='O')
{
count=count+1;
}
}
cout<<"Jumlah konsonan character : "<<nama.length()-count;
}
int main()
{
cout<<"Silahkan pilih menu di bawah :\n";
cout<<"1. Reverse word\n";
cout<<"2. Count vocal character\n";
cout<<"3. Count konsonan character\n";
cout<<"Pilihan Anda (1/2/3) : ";
cin>>pilihan;
if(pilihan==1)
{
cout<<"Masukan nama : ";
cin>>nama;
reverse(nama);
}
else if(pilihan==2)
{
cout<<"Masukan nama : ";
cin>>nama;
hitungaiueo(nama);
}
else if(pilihan==3)
{
cout<<"Masukan nama : ";
cin>>nama;
hitungkonsonan(nama);
}
else
cout<<"Pilihan hanya 1, 2 atau 3.\n";
return 0;
}
I gotta favorite this website it seems very helpful . word counter tool
ReplyDelete