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

How do I make it so that a valid dict string will have all thewords in alphabeti

ID: 3613179 • Letter: H

Question

How do I make it so that a valid dict string will have all thewords in alphabetical order?
String dict,text,word;
int num=0,end=0,i;
Scanner in=new Scanner(System.in);
System.out.println("enter the dictionary");
dict=in.nextLine();
dict=dict.toLowerCase();
System.out.println("enter the words to check for");
text=in.nextLine();
text=text.toLowerCase();
i=0;
while(i<text.length())

etc.
String dict,text,word;
int num=0,end=0,i;
Scanner in=new Scanner(System.in);
System.out.println("enter the dictionary");
dict=in.nextLine();
dict=dict.toLowerCase();
System.out.println("enter the words to check for");
text=in.nextLine();
text=text.toLowerCase();
i=0;
while(i<text.length())

etc.

Explanation / Answer

You can check whether a dict string has all the words inalphabetical order by splitting words with a Scanner and comparingthem. publicboolean checkDict(String dict) { // chop dict usingscanner Scannerchopper=new Scanner(dict); // local variables tocheck strings StringlastWord=chopper.next(); Stringnext=""; // while dict hasanother word while(chopper.hasNext()) { next=chopper.next(); //compare next to lastWord if(next.compareTo(lastWord)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote