Upload files to "OOP/Java/Lab/Week9"
This commit is contained in:
parent
e9a4ce08c7
commit
cd43a87e9b
5 changed files with 99 additions and 0 deletions
24
OOP/Java/Lab/Week9/three_letter.java
Normal file
24
OOP/Java/Lab/Week9/three_letter.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class three_letter {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Enter a five-letter word: ");
|
||||
String word = sc.nextLine();
|
||||
|
||||
if (word.length() != 5) {
|
||||
System.out.println("Please enter a valid five-letter word.");
|
||||
} else {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int j = 0; j < 5; j++) {
|
||||
for (int k = 0; k < 5;s k++) {
|
||||
if (i != j && j != k && i != k) {
|
||||
String threeLetterWord = "" + word.charAt(i) + word.charAt(j) + word.charAt(k);
|
||||
System.out.println(threeLetterWord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue