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

Need help creating code from the task below For this lab, you will continue to p

ID: 3825299 • Letter: N

Question

Need help creating code from the task below

For this lab, you will continue to practice manipulating strings. You are to write a Java application that Creates an ID from two words. The ID has the from: LastHalfOfWord1 + LengthOfWord2 + UppercaseFirstLetterOfWord2 For example, if the two words are George and Washington, the ID will be rge10W Extracts a file extension from a file path. For example, if the file path is/some/path/to/file/myfile.java, the program would print: The file extension is ".java". In "Develop" mode, you can run your program as often as you'd like, before submitting for grading. Type input values (if desired) in the first box below, then click "Run program" and observe the program's output in the second box.

Explanation / Answer

import java.util.*;

public class HelloWorld{

public static void main(String []args){
//System.out.println("Hello World");
Scanner sc=new Scanner(System.in);
System.out.println("Enter Two words");
String Word1=sc.next();
String Word2=sc.next();
String ID;
int length1=Word1.length();
int length2=Word2.length();
String LastHalfOfWord1=Word1.substring(length1/2,length1);
// System.out.println(LastHalfOfWord1);
String UpperCaseFirstLetterOfWord2=Word2.substring(0,1).toUpperCase();
ID=LastHalfOfWord1+length2+UpperCaseFirstLetterOfWord2;
System.out.println("id for 2 words: "+ID);
System.out.println("enter the file path");
String filePath=sc.next();
String []extension =filePath.split("\.");
//System.out.println(filePath);
String ext1=extension[0];
String ext2=extension[1];
System.out.println("extension for file path : ."+ext2);

}
}

output:

sh-4.3$ javac HelloWorld.java                                                                                                                                                   

sh-4.3$ java -Xmx128M -Xms16M HelloWorld                                                                                                                                        

Enter Two words                                                                                                                                                                 

hello world                                                                                                                                                                     

id for 2 words:    llo5W                                                                                                                                                        

enter the file path                                                                                                                                                             

dd/fgfg/hhh/.java                                                                                                                                                               

extension for file path : .java

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