Created
November 3, 2019 13:11
-
-
Save emreedemir/7638c01c19e850d34b6bb682601575e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Main | |
{ | |
static char[] alphabet= {'a','b','c','d','e' | |
,'d','f','g','i','j' | |
,'k','l','m','n','p' | |
,'r','s','t','y','v' | |
,'z','x','w'}; | |
public static void main(String[] args) | |
{ | |
char[] testRandomCharacter = new char[100]; | |
for(int i =0;i<testRandomCharacter.length;i++) | |
{ | |
testRandomCharacter[i]=getRandomCharacter(); | |
} | |
printCharacterCount(testRandomCharacter); | |
} | |
static char getRandomCharacter() | |
{ | |
int randomNumber = (int)(Math.random() * alphabet.length ); | |
return alphabet[randomNumber]; | |
} | |
static void printCharacterCount(char[] randomCharactersArray) | |
{ | |
for(int i=0;i<alphabet.length;i++) | |
{ | |
int characterCount =0; | |
for(int j=0;j<randomCharactersArray.length;j++) | |
{ | |
if(alphabet[i]==randomCharactersArray[j]) | |
{ | |
characterCount++; | |
} | |
} | |
if(characterCount>0) | |
{ | |
System.out.println("Character is " +alphabet[i] +" Count is" +characterCount); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Main | |
{ | |
static char[] alphabet= {'a','b','c','d','e' | |
,'d','f','g','i','j' | |
,'k','l','m','n','p' | |
,'r','s','t','y','v' | |
,'z','x','w'}; | |
public static void main(String[] args) | |
{ | |
char[] testRandomCharacter = new char[100]; | |
for(int i =0;i<testRandomCharacter.length;i++) | |
{ | |
testRandomCharacter[i]=getRandomCharacter(); | |
} | |
printCharacterCount(testRandomCharacter); | |
} | |
static char getRandomCharacter() | |
{ | |
//burda random sayı alıyoruz 0 dan alphabet arrayında ki eleman sayısı aralıgında | |
int randomNumber = (int)(Math.random() * alphabet.length ); | |
//burdada return ediyoruz alfabeden | |
return alphabet[randomNumber]; | |
} | |
//karakter sayısını hesaplıyoruz. | |
static void printCharacterCount(char[] randomCharactersArray) | |
{ | |
for(int i=0;i<alphabet.length;i++) | |
{ | |
int characterCount =0; | |
for(int j=0;j<randomCharactersArray.length;j++) | |
{ | |
if(alphabet[i]==randomCharactersArray[j]) | |
{ | |
characterCount++; | |
} | |
} | |
if(characterCount>0) | |
{ | |
System.out.println("Character is " +alphabet[i] +" Count is" +characterCount); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment