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

Hi! I\'m learning the scanner in my java class. I had aquestion about a program:

ID: 3614386 • Letter: H

Question

Hi! I'm learning the scanner in my java class. I had aquestion about a program: Write a program that takes three words of input from the user,converts that input to UPPERCASE and prints it out, then convertsthe data to lowercase and prints it out. Finally, have the programtake the LAST word and move it the the first word position. How do I do this with "scanner"? Hi! I'm learning the scanner in my java class. I had aquestion about a program: Write a program that takes three words of input from the user,converts that input to UPPERCASE and prints it out, then convertsthe data to lowercase and prints it out. Finally, have the programtake the LAST word and move it the the first word position. How do I do this with "scanner"?

Explanation / Answer

First we need to inport Scanner: importjava.util.Scanner; Now we can use it for input in main(): public staticvoid main(String[] args) { // create scanner toread input Scanner kb= newScanner(System.in); // prompt for userinput System.out.print("Enterthree words: "); // read threewords String word1= kb.next(); String word2= kb.next(); String word3= kb.next(); // combinewords String combined= word1+" "+word2+" "+word3; // convert to uppercase combined =combined.toUpperCase(); // output uppercase System.out.println(combined); // convert to lowercase combined =combined.toLowerCase(); // output lowercase System.out.println(combined); // put 3rd word in frontof first combined =word3+""+word1+" "+word2; // convert to lower caseagain (because we used the original input) combined =combined.toLowerCase(); // output System.out.println(combined); } Note: the above code reads each word separately,which makes dealing with them more clear.

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