Write pseudocode for a program that reads a word and then pr

Write pseudocode for a program that reads a word and then prints the first character, the last character, and the characters in the middle. For example, if the input is Harry, the program prints H y arr. Implement the algorithm in Java, asking the word from the user.

Solution

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;

import java.util.Scanner;


public class Word {


public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println(\"Enter a word:\");
String word = input.next();
  
int len = word.length();
  
if(len>1)
{
System.out.println(word.charAt(0)+\" \"+word.charAt(len-1)+\" \"+word.substring(1, len-1));
}
else
{
System.out.println(word.charAt(0)+\" \"+word.charAt(0)+\" \"+word.substring(0, len-1));
}
}
  
}

Write pseudocode for a program that reads a word and then prints the first character, the last character, and the characters in the middle. For example, if the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site