User inserting Alphabet into array and controlling if there are repetitions and order of input Java -


i need create array of 26 , insert in alphabet letters, have control if there repetitions , order of input eg: a,b,c or z,y,x.

my code:

import java.util.scanner;  public class esercizio4 {     scanner sc = new scanner(system.in);     private int ripetions;      public esercizio4(){           char alfa[] = new char[26];         (int i=0;i<=26;i++){             system.out.println("insert letter");             alfa[i]=sc.next().charat(0);         }     } } 

i googled how make control of input being correct (accepting letters) couldn't find or hard understand. second part might easier still how control if there repetitions , if order increasing/decreasing (a,b,c/z,x,y).

to know if char letter have compare numerical representation of char.

have @ table

i.e.:

the letter a = 97 while a = 65.

what tells char can range between value of 97 - 122 lowercase letters , 65 - 90 capital letters.

then question of looping trough array , comparing values figure out if have repetitions or invalid characters!

ps: can use values re-order array. check out sorting algorythms.

java sorting algorythms


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -