Skip to content

juliamac329/Working-With-Java-String-Variables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Working-With-Java-String-Variables

ICS4U String Assignment

Program #1: Basic String Functions

Instruction: Created a file named Strings1.java and the appropriate class code and main function. Cut and paste this program into java. String b = "Banana Split"; System.out.println (b.length ()); System.out.println (b.charAt (3)); System.out.println (b.charAt (b.length () - 1)); System.out.println (b.replace ('a', 'g')); System.out.println (b.toUpperCase ()); System.out.println (b.toLowerCase ()); System.out.println ((int) (b.charAt (0))); Examine the output of the above code to determine what each of the functions do. Copy the code below into your java main function. Follow the instructions in the comments to make your program output the answer attach your java files to this assignment and submit when the entire assignment is complete. . Starter Code:

public class Strings1 { public static void main (String args[]) { String jj = "John Jacob Jingleheimer Schmidt"; //1. print all capitals //2. print all lowercase //3. replace a with @ //4. replace e with # //5. replace i with ^ //6. replace o with + //7. replace u with & //8. print out the 2nd character //9. print out the 3rd character //10. print out the 8th character //11. print out the last character //12. print out the 2nd last character //13. print out the middle character //14. print out the length //15. print out the length/2 //16. print out the ASCII value of the 5th character //17. print out the ASCII value of the 11th character //18. print out the ASCII value of the 15th character } }

Program #2: Manipulating Strings using String Functions

Instruction: Created a file named Strings2.java and the appropriate class code and main function. Attach your java files to this assignment and submit when the entire assignment is complete.

Create a java program that Has the user enter their first, middle and last name with spaces separating them. Any name could be entered Every name will have a first, middle and last name. Then, you will print out: (a) Their first name (b) Their last name (c) Their middle name (d) Their initials (e) Their username is created by using → first initial, middle initial, last name.

For example: Name? Ned Everett Body First Name: Ned Last Name: Body Middle Name: Everett Initials: NED Username: nebody

About

ICS4U String Assignment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages