Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a JAVA program that does all of the following: • It allows the user to in

ID: 3696064 • Letter: D

Question

Design a JAVA program that does all of the following:

• It allows the user to input a three letter word.

• It saves this word in an array / string.

• Then the program randomly picks a letter from the 26 letters of the alphabet and uses that letter to replace the first letter of the 3-letter word.

• The program checks if the randomly selected letter matches the first letter of the 3-letter word. If it does not, the program proceeds to the next letter and replaces it with a letter randomly selected from the 26 letters of the alphabet;

• If the randomly selected letter matches the first letter of the 3-letter word, the program randomly selects another letter and repeats that process until the randomly selected letter is different from the first letter of the 3-letter word.

****Please show a picture of your output and your code so there aren't any spacing issues.****

Explanation / Answer

RandomLetter.java

package org.students;

import java.util.Random;
import java.util.Scanner;

public class RandomLetter {

   public static void main(String[] args) {
       String str;char letter,symbol;
       Scanner sc=new Scanner(System.in);
       System.out.print("Enter a word::");
       str=sc.next();
       while(true)
           {
           letter=str.charAt(0);
           Random r = new Random();
           symbol = (char)(r.nextInt(26) + 'a');
           String str1=str.substring(1);
           str1=symbol+str1;
          
           System.out.println(str1);
           if(letter!=symbol)
               continue;
           //else if(letter==symbol)
           //   continue;
           else
               break;
          
          
       }
  

   }

}

_______________________________________________________________________________________

output:

Enter a word::pen
zen
ben
ben
aen
sen
ven
yen
nen
hen
ten
zen
yen
len
ren
xen
hen
len
aen
ben
den
ien
hen
aen
xen
ben
aen
zen
ben
ten
oen
ren
nen
ken
ven
ren
men
len
nen
wen
sen
yen
yen
qen
qen
ten
uen
xen
hen
ken
zen
zen
fen
jen
gen
oen
aen
den
men
ren
nen
oen
len
len
aen
pen