Write a Java program that compares two Strings. You have to declare a String text1 and assign it the value "programming" and then declare another String text2 and assign it the value "development". Your program should do the following:

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question
Description

Write a Java program that compares two Strings. You have to declare a String text1 and assign it the value "programming" and then declare another String text2 and assign it the value "development". Your program should do the following:

  1. If the two Strings are exactly the same print to the screen "Exactly the same: True" otherwise print "Exactly the same: False". You may use boolean variables.
  2. If and only if the first comparison was false, a comparison should be done that ignores case sensitivity. If they are the same while ignoring the case print to the screen "Similar: True" otherwise print "Similar: False".

 

Sample Input

These sentences are the same. These sentences are the same.

Sample Output

Exactly the same: True

Sample Input

This sentence has Upper case and Lower case letters. This sentence has upper case and lower case letters.

Sample Output

Exactly the same: False Similar: True

Sample Input

Well something is wrong here Obviously they will get a false output

Sample Output

Exactly the same: False Similar: False

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Files and Directory
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT