Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Esercizio {
- public static void main (String [] args){
- String s1 = new String("abcdefghijklmnopqrstuvwxyz");
- char [] rmd = new char [10];
- for (int i=0;i<10;i++) {
- int Lettere = (int) (Math.random()*s1.length()-1);
- rmd[i] = s1.charAt(Lettere);
- System.out.println(rmd[i]);
- }
- System.out.println("Scrivi il carattere da cercare: ");
- char letto = (System.console(). readLine()).charAt(0);
- int cont = 0;
- while ((cont<rmd.length-1) && (rmd[cont]!=letto)) {
- cont++;
- }
- if (rmd[cont]==letto) {
- System.out.println("Il carattere e' contenuta nella stringa");
- }
- else {
- System.out.println("Il carattere non e' contenuta nella stringa");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement