Java Write an executable program that has just a main method. In main: create an instance of StringBuilder that initially holds an empty string. append your first name to the string. append your surname to the string. display your name. insert your middle initial where it should be and spaces as needed. If you don't have a middle name, fake it. display your name with middle initial. delete your initial and the space(s). display your name in reverse order.  SAMPLE OUTPUT John Public John Q Public cilbuP nhoJ

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

 Java

Write an executable program that has just a main method. In main:

  • create an instance of StringBuilder that initially holds an empty string.
  • append your first name to the string.
  • append your surname to the string.
  • display your name.
  • insert your middle initial where it should be and spaces as needed. If you don't have a middle name, fake it.
  • display your name with middle initial.
  • delete your initial and the space(s).
  • display your name in reverse order. 

SAMPLE OUTPUT

John Public
John Q Public
cilbuP nhoJ

Expert Solution
Step 1: Introduction

In main function:

  • create an instance of StringBuilder that initially holds an empty string.
  • append your first name to the string.
  • append your surname to the string.
  • display your name.
  • insert your middle initial where it should be and spaces as needed. If you don't have a middle name, fake it.
  • display your name with middle initial.
  • delete your initial and the space(s).
  • display your name in reverse order. 
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Methods of StringBuilder class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT