Question

1. Create a NetBeans project under the name PlayingWithJavaStrings. 2. In the source code do the...

1. Create a NetBeans project under the name PlayingWithJavaStrings.

2. In the source code do the following:

i) Create two separated String variables, one for the first and the other for the last names and set them to “John” and “Smith”, respectively.

ii) Create a String variable for the full name and then concatenate the first and last name variables into it.

3. Using the String methods found in the Java API:

  1. Print the full name in the terminal window
  2. print in the terminal window the contents of the full name variable in all CAPITAL LETTERS
  3. same as above but all in lower case letters
  4. Print the number of letters that the full name has
  5. Print the 6th letter of the full name
  6. Create two more String objects with the contents of “Mary” (first name) and “Smith” (last name). Compare if John and Mary have the same last name and if so print that they are related, otherwise that they are not

solve using java

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

public class Test{

public static void main(String []args){
String first="John";
String last="Smith";
String full_name=first+" "+last;
System.out.println(full_name);
System.out.println(full_name.toUpperCase());
System.out.println(full_name.toLowerCase());
System.out.println("Number of letters are: "+full_name.length());
System.out.println("6th letter is: "+full_name.charAt(5));
String first2="Marry";
String last2="Smith";
if(last.equals(last2))
System.out.println(first+" and "+first2+" are related");
else
System.out.println(first+" and "+first2+" are not related");
}
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
1. Create a NetBeans project under the name PlayingWithJavaStrings. 2. In the source code do the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need Java help: 1. Create a Java program that accepts input String input from a user...

    Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.

  • Task #1 Create a program that: 1. Has a comment in the JavaScript code with your...

    Task #1 Create a program that: 1. Has a comment in the JavaScript code with your name and student number 2. Asks the user for their first name with a pop-up prompt screen. Explorer User Prompt Script Prompt: ок Enter your first name: Cancel Joel 3. Asks the user for their last name with a pop-up prompt screen. Explorer User Prompt X Saript Prompt: ок Enter your last name: Cancel Smith 4. Performs string concatenation to combine their first and...

  • JAVA LANG PACKAGE Create a NetBeans project for this activity. 1: Create a new class with...

    JAVA LANG PACKAGE Create a NetBeans project for this activity. 1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. Now override the to String() method. 2: Create a class with the main method and create an instance of the class that you created 3: Create an instance of the string in your test class and assign a value. 4: Now create an String...

  • java Part 1 Create a NetBeans project that asks for a file name. The file should...

    java Part 1 Create a NetBeans project that asks for a file name. The file should contain an unknown quantity of double numeric values with each number on its own line. There should be no empty lines. Open the file and read the numbers. Print the sum, average, and the count of the numbers. Be sure to label the outputs very clearly. Read the file values as Strings and use Double.parseDouble() to convert them. Part 2 Create a NetBeans project...

  • Java - In NetBeans IDE: • Create a class called Student which stores: - the name...

    Java - In NetBeans IDE: • Create a class called Student which stores: - the name of the student - the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into...

  • Start a new project in NetBeans that defines a class Person with the following: Instance variables...

    Start a new project in NetBeans that defines a class Person with the following: Instance variables firstName (type String), middleInitial (type char) and lastName (type String) (1) A no-parameter constructor with a call to the this constructor; and (2) a constructor with String, char, String parameters (assign the parameters directly to the instance variables in this constructor--see info regarding the elimination of set methods below) Accessor (get) methods for all three instance variables (no set methods are required which makes...

  • Hi, I need help with this Java activity. The requirements are: 1. Create a NetBeans project...

    Hi, I need help with this Java activity. The requirements are: 1. Create a NetBeans project for this activity. 2. Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. 3. Create a class with the main method and create an instance of the class that you created in Test Stem 1. 4. Create an instance of the string in your test class and assign...

  • signature 1. Create a new NetBeans Java project. The name of the project has to be...

    signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...

  • 1. What kind of exception will be generated when the code segment below is executed? Why?...

    1. What kind of exception will be generated when the code segment below is executed? Why? int numerator 10; int denominator 0; int wholePart numerator/denominator Questions 2 and 3 refer to the Person constructor below. Person constructor has two String parameters, a first nam and a last name. the constructor initializes the e-mail address to the first letter of the first name followed by the fir five letters of the last name followed by @jc.com. If the last name has...

  • Deliverable A zipped NetBeans project with 2 classes app ZipCode Address Classes Suggestion: Use Netbeans to...

    Deliverable A zipped NetBeans project with 2 classes app ZipCode Address Classes Suggestion: Use Netbeans to copy your last lab (Lab 03) to a new project called Lab04. Close Lab03. Work on the new Lab04 project then. The Address Class Attributes int number String name String type ZipCode zip String state Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: number - 0 name - "N/A" type...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT