
For each problem, use a java scripting on the problem and put the number assigned problem followed by whatever output the task requires. Output a blank line between problems.
1.the user to enter a two words for this problem.
a. Print the shorter word (the one with fewer characters), followed by the longer word.
b. Print the words in alphabetical order.

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
let x=window.prompt("Enter first string");
let y=window.prompt("Enter second string");
if (x.length<y.length) {
let arr=[];
let i=0;
while(i<x.length)
{
arr[i]=x[i];
i=i+1;
}
document.getElementById("demo").innerHTML = arr.sort();
}
else{
let arr=[];
let i=0;
while(i<y.length)
{
arr[i]=y[i];
i=i+1;
}
document.getElementById("demo").innerHTML = arr.sort();
}
</script>
</body>
</html>
Step by stepSolved in 2 steps

- Write the necessary Java statements (not necessarily programs) to achieve the indicated task. To display the string CUNY 50 times on the screen on separate lines. Need to use a loop.arrow_forwardWrite Java statements (not necessarily complete programs) to achieve indicated task. To read an string from the keyboard (when the user enters it) and display the first character of the string on the screen.arrow_forwardWrite a Java Program to take a string from the user and your task is to print the length of the longest palindromic string which can be formed from the user. per string character.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





