java 输出单词_关于JAVA输出单词首字母的程序

WriteacompleteJavaprograminasourcefiletobenamedAssignment3.java.Theprogramaskstheuserfortheirfullname(firstmiddlelast-usingnextLinemethod)asonestringinanycombinationofupp...

Write a complete Java program in a source file to be named Assignment3.java.

The program asks the user for their full name (first middle last-using nextLine method) as one string in any combination of upper and lower case. Your task is to output the name in the following variations:

• Print just the initials in upper case letters

• Print the last name in upper case followed by a comma and the first name in lower case with the first letter capitalized and the middle initial capitalized followed by a period

• Print the last name comma first name and middle name – all names with first letter capitalized.

Note: Your program has to check for middle name and if the user does not have a middle name your program has to print the variations without the middle name. See the sample output below

Important: You will not get points if you do not read the string as one line (Use scan.nextLine()). You cannot use the Scanner class for extracting different parts of the name. You have to use the methods in class String

Here is the output your program should produce when the user enters the string shown in bold:

Sample Output: (the user enters the string shown in bold)

Sample output 1:

What are your first, middle, and last names?

david john smith

Your initials are: DJS

Variation one: SMITH, David J.

Variation two: Smith, David John

Sample output 2:

What are your first, middle and last names?

Faye Navabi

Your initials are: FN

Variation One: NAVABI, Faye

Variation Two: Navabi, Faye

Sample output 3:

What are your first, middle and last names?

Johnson

Wrong. Please enter your names properly.

这个程序该怎么写呢,谢谢!

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值