PART 2: Variables, Constants, and Arithmetic The following are sample runs of the program to help you write your code and format your output: Sample Output 1: Please enter your first name: Alfred Please enter your last name: Johnson W/ Hello Alfred Johnson //\ The length of your full name is 13 characters Your standard username is: AJohnson Your initials are: A.J. If we switch the first and last characters of your first name, we get: dlfrea ----jGRASP: operation complete. Sample Output 2: Please enter your first name: Jennifer Please enter your last name: Todd W/ Hello Jennifer Todd // The length of your full name is 12 characters Your standard usexname is: JTodd Your initials are: J.T. If we switch the first and last characters of your first name, we get: rennifeJ ----jGRASP: operation complete. Instructions for Part 2: 1. Go to the following URL to complete the project: Project 1 B 2. If using and IDE (JGrasp or Eclipse), create a new class file named StringFun.java (optional) 3. You will be filling in code everywhere you see the ellipses (...) in the code. Please follow the instructions and use the Sample Outputs to guide you. 4. Write the Class comment and gauthor and Qvezsion tags 5. Create a variable to store the input for the first name and use a Scanner method to read the value from the Console. 6. Create a variable to store the input for the last name and use a Scanner method to read the value from the Console. 7. Output the welcome message with concatenated full name and the escape strings (see sample output). Use your variables from Steps 5 & 6. 8. Output the standard username of the user using methods of the String class (to get first initial) and concatenation. 9. Output the initials of the user using methods of the String class and concatenation. 10. Declare an integer variable to store the last index of the first name. Use a method of the String class to assign this index to the variable. 11. Declare a String variable to store the switched first and last letters of the first name. 12. Use method(s) of the String class (substring, charAt, length) to assign the switched name to the variable. See 2.5.6 and substring video in iCollege additional videos 13. Output the switched name (see sample output). 14. Submit your code and check the tests and correct any error messages or output formatting issues.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
PART 2: Variables, Constants, and Arithmetic
The following are sample runs of the program to help you write your code and
format your output:
Sample Output 1:
Please enter your first name: Alfred
Please enter your last name: Johnson
W/ Hello Alfred Johnson //\\
The length of your full name is 13 characters
Your standard username is: AJohnson
Your initials are: A.J.
If we switch the first and last characters of your first
name, we get: dlfreA
----jGRASP: operation complete.
Sample Output 2:
Please enter your f£irst name: Jennifer
Please enter your last name: Todd
W/ Hello Jennifer Todd //\\
The length of your full name is 12 characters
Your standard userame is: JTodd
Your initials are: J.T.
If we switch the first and last characters of your first
name, we get: rennifeJ
----jGRASP: operation complete.
Instructions for Part 2:
1. Go to the following URL to complete the project: Project 1B
2. If using and IDE (jGrasp or Eclipse), create a new class file named
StringFun.java (optional)
3. You will be filling in code everywhere you see the ellipses (...) in the code.
Please follow the instructions and use the Sample Outputs to guide you.
4. Write the Class comment and eauthor and eversion tags
5. Create a variable to store the input for the first name and use a Scanner
method to read the value from the Console.
6. Create a variable to store the input for the last name and use a Scanner
method to read the value from the Console.
7. Output the welcome message with concatenated full name and the escape
strings (see sample output). Use your variables from Steps 5 & 6.
8. Output the standard username of the user using methods of the String class (to
get first initial) and concatenation.
9. Output the initials of the user using methods of the String class and
concatenation.
10. Declare an integer variable to store the last index of the first name. Use a
method of the String class to assign this index to the variable.
11. Declare a String variable to store the switched first and last letters of the first
name.
12. Use method(s) of the String class (substring, charAt, length) to assign the
switched name to the variable. See 2.5.6 and substring video in iCollege
additional videos
13. Output the switched name (see sample output).
14. Submit your code and check the tests and correct any error messages or
output formatting issues.
Transcribed Image Text:PART 2: Variables, Constants, and Arithmetic The following are sample runs of the program to help you write your code and format your output: Sample Output 1: Please enter your first name: Alfred Please enter your last name: Johnson W/ Hello Alfred Johnson //\\ The length of your full name is 13 characters Your standard username is: AJohnson Your initials are: A.J. If we switch the first and last characters of your first name, we get: dlfreA ----jGRASP: operation complete. Sample Output 2: Please enter your f£irst name: Jennifer Please enter your last name: Todd W/ Hello Jennifer Todd //\\ The length of your full name is 12 characters Your standard userame is: JTodd Your initials are: J.T. If we switch the first and last characters of your first name, we get: rennifeJ ----jGRASP: operation complete. Instructions for Part 2: 1. Go to the following URL to complete the project: Project 1B 2. If using and IDE (jGrasp or Eclipse), create a new class file named StringFun.java (optional) 3. You will be filling in code everywhere you see the ellipses (...) in the code. Please follow the instructions and use the Sample Outputs to guide you. 4. Write the Class comment and eauthor and eversion tags 5. Create a variable to store the input for the first name and use a Scanner method to read the value from the Console. 6. Create a variable to store the input for the last name and use a Scanner method to read the value from the Console. 7. Output the welcome message with concatenated full name and the escape strings (see sample output). Use your variables from Steps 5 & 6. 8. Output the standard username of the user using methods of the String class (to get first initial) and concatenation. 9. Output the initials of the user using methods of the String class and concatenation. 10. Declare an integer variable to store the last index of the first name. Use a method of the String class to assign this index to the variable. 11. Declare a String variable to store the switched first and last letters of the first name. 12. Use method(s) of the String class (substring, charAt, length) to assign the switched name to the variable. See 2.5.6 and substring video in iCollege additional videos 13. Output the switched name (see sample output). 14. Submit your code and check the tests and correct any error messages or output formatting issues.
StringFun.java
import java.util.Scanner; // Needed for the Scanner class
2
3
/** Add a class comment and @tags
4
5
*/
6
7
public class StringFun
{
/**
* @param args not used
8
9
10
11
12
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Please enter your first name: ");
13
14
15
16
17
18
System.out.print("Please enter your last name: ");
19
20
21
//Output the welcome message with name
22
23
24
//Output the length of the name
25
26
27
//Output the username
28
29
30
//Output the initials
31
32
33
//Find and output the first name with switched characters
34
//All Done!
}
}
35
36
37
Transcribed Image Text:StringFun.java import java.util.Scanner; // Needed for the Scanner class 2 3 /** Add a class comment and @tags 4 5 */ 6 7 public class StringFun { /** * @param args not used 8 9 10 11 12 public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Please enter your first name: "); 13 14 15 16 17 18 System.out.print("Please enter your last name: "); 19 20 21 //Output the welcome message with name 22 23 24 //Output the length of the name 25 26 27 //Output the username 28 29 30 //Output the initials 31 32 33 //Find and output the first name with switched characters 34 //All Done! } } 35 36 37
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Types of Function
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education