Intro to JAVA please see below: ------------------------------------------------
ID: 3917023 • Letter: I
Question
Intro to JAVA please see below:
---------------------------------------------------
Complete the given program DuplicatedCharacters The program reads one word and checks if there is any duplicated character in the word. If there is, it prints "There is a duplicated character.". Otherwise, it prints "All letters are unique." Hint: The String class provides you with the following methods: public boolean contains(String s) Returns: true if this string contains s, false otherwise . public String substring(int beginIndex, int endIndex) Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex -1. import java.util1.scanner public class DuplicatedCharacters public static void main(String args) Scanner in-new Scanner (System.in) System.out.print("Enter a word: "); String s -in.next); /1 Your work goes here. Here are the expected outputs from several runs of this program Enter a word: apple There is a duplicated letter Enter a word: student There is a duplicated letter. Enter a word: desk All letters are uniqueExplanation / Answer
import java.util.Scanner; public class DuplicatedCharacters { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a word: "); String s = in.next(); boolean duplicateFound = false; for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.