Question

The String Class: 1a.) Given the following delcaration: String modification1; Write a statement that stores the...

The String Class:

1a.) Given the following delcaration:

String modification1;

Write a statement that stores the uppercase equivalent of the string object called "city" in modification1.

1b.) Write a statement that declares a String variable named city. The variable should be initialized with the string literal "Los Angeles".

1c.) Given the following declaration:

int stringSize;

Write a statement that stores the length of the string object called "city" in stringSize.

1d.) Given the following declaration:

char oneChar;

Write a statement that stores the third character of the string object called "city" in oneChar.

1e.) Given the following delcaration:

String modification2;

Write a statement that replaces all the characters 'e' by # in the string object 'city', and stores the modified string in the modification2.

1f.) Given the following delcaration:

String modification3;

Write a statement that stores the lowercase equivalent of the string object 'city' in modification3.

Homework Answers

Answer #1

1.a:
modification1 = city.toUpperCase();
1.b:
String city = "Los Angeles"
1.c:
//to get size we can use length() method
stringSize = city.length();

1.d:
oneChar = city.charAt(2);
// 3rd will be stores at index 2 as indexes starts from 0

1.e:
modification2= city.replaceAll("e","#");
1.f:
modification3 = city.toLowerCase();

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
If and else statements: 1a.) Given the following declaration: int temperature; Write an if statement that...
If and else statements: 1a.) Given the following declaration: int temperature; Write an if statement that prints the message "The number is valid" if the variable temperature is within the range of -50 trough 150 (both values excluded). 1b.) Given the following declarations int x; int y; Write an if statement that assigns 100 to x when y is equal to 0. 1c.) Given the following declaration: int grade; Write an if statement that prints the message "The number is...
write a statement that declares char variable named gender initialized to the character m in c++...
write a statement that declares char variable named gender initialized to the character m in c++ additionally, What is the value of number after the following code executes? int a=5; int b=10; int number = a++ + b++; lastly, The break; is required in every case block of a switch statement true or false and A default block is required in every switch statement true or false
Practice manipulating an object by calling its methods. Complete the class Homework1 class using String methods....
Practice manipulating an object by calling its methods. Complete the class Homework1 class using String methods. Remember that all the String methods are accessors. They do not change the original String. If you want to apply multiple methods to a String, you will need to save the return value in a variable. Complete the class by doing the following: + Print the word in lowercase + Replace "e" with "3" (Use the unmodified variable word) + Print the changed word...
Using python, please do the following. 1. Write regular expressions. (a) Capture any string that contains...
Using python, please do the following. 1. Write regular expressions. (a) Capture any string that contains at least three digits. (b) Capture any word that starts with one lowercase character, and either ends with two digits or with three vowels. 2. Given the following statements: string = """ Supreme executive power derives from a mandate from the masses , not from some farcical aquatic ceremony .""" words = string . split () Write a short program, using the re module,...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
Write a class called Item that has a string field called name and a double field...
Write a class called Item that has a string field called name and a double field called price and an integer field called quantity. In main, create a bag of type Item and place several item objects in the bag. Then in main calculate the total price of items purchased. You may remove each item and add the price to a total variable in a loop. The loop should end when the bag is empty. Using bag algorithms public final...
Part 1 Given the following code: public class MyClass { private double score; private String studentID;...
Part 1 Given the following code: public class MyClass { private double score; private String studentID; //code of the class ..... } //end of MyClass Code a default constructor and an overloaded constructor of MyClass that will assign values to its two instance fields: Please write in JAVA Part 2 Continue from question about, code an mutator of instance field called studentID:
AP Computer Science A FRQ SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE...
AP Computer Science A FRQ SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT