1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
rewona [7]
3 years ago
8

Write a program that asks the user for three strings. Then, print out whether the first string concatenated to the second string

is equal to the third string. Here are a few sample program runs: Sample Program 1: First string
Computers and Technology
1 answer:
zepelin [54]3 years ago
5 0

Answer:

import java.util.Scanner;

public class Main {

   public static void main(String[] args) throws Exception {

          Scanner myObj = new Scanner(System.in);

        //Request and receive first String

       System.out.println("Enter username");

       String firstString = myObj.nextLine();

       

       //Request and receive second string

       System.out.println("Enter second string");

       String secondString = myObj.nextLine();

       

         //Request and receive third string

       System.out.println("Enter third string");

       String thirdString = myObj.nextLine();

       //Concatenate the first and second string

       String concatA_B = firstString + secondString;

       

       if(concatA_B.equals(thirdString)){

           System.out.println("First String Concatenated to Second String is equals to the third String");

       }

       else{

            System.out.println("First String Concatenated to Second String is NOT equals to the third String");

       }

   }

}

Explanation:

  • Import Scanner Class
  • Request and Receive three variables from the user using the Scanner Class
  • Concatenate the first and second
  • Use the .equals() method to check for equality
You might be interested in
"while executing programs from the command line, most operating systems also allow the user to specify one or more ____________
Rudik [331]
The answer could possibly be "parameters"
6 0
3 years ago
Which of these statements about cell references isn’t true
vampirchik [111]

Answer:

No Question and I don't really know the answer Pleasesend the question again

4 0
2 years ago
Write a program whose input is an email address, and whose output is the username on one line and the domain on the second. Exam
kirill115 [55]

Answer:

1 void parseEmailAddress(string email, string& username, string& domain)

2 {

3   int found = email.find("@")

4   if (found > 0)

5   {  

6     username = email.substr(0, found);  

7      domain = email.substr(found+1, -1);

8   }

9   return;

10}

Explanation line by line:

  1. We define our function.
  2. We use an open curly bracket to tell the program that we are starting to write the function down.
  3. We apply the find method to the email variable that was passed by the main program. The find method tells us where is the "@" located within the email.
  4. We use an if statement to ensure that the value that we found is positive (The value is negative if an only if "@" is not in the email address).
  5. We use an open curly bracket to tell the program that we are starting to write inside the if statement.
  6. We apply the substr method to the email to take the username; it receives a start and an end value, this allows us to take from the beginning of the email (position 0) until the "@".  
  7. We apply the substr method to the email to take the domain; it receives the position of the "@" character plus one to take the first letter after the "@" and a minus-one representing the last character on the email.
  8. We use a closing curly bracket to tell the program that the if statement has finished.
  9. We return nothing because we are using reference parameters, which means that the memory positions of username and domain are going to be filled by our parseEmailAddress function and the main function can access those values directly.
  10. We use a closing curly bracket to tell the program that the function has finished.
6 0
3 years ago
How does a clock work
Free_Kalibri [48]

Sets of gears move inside of it that persicely move the hands onto the time. That's why watches can be so intricate and valuable.

If your looking for how to read one, it's pretty straightforward if you look it up online.

3 0
3 years ago
Read 2 more answers
Which of the following is a category of authentication tools. A something you have B something u see c something you hear d some
Alja [10]

Answer:

Explanation:

Something you have.

5 0
3 years ago
Read 2 more answers
Other questions:
  • A new version of an existing software program is considered a ________technology
    12·1 answer
  • For your biology class, you have taken a number of measurements for A plant growth experiment. you wish to create a chart that s
    6·1 answer
  • If you want to open an application that does not have a tile pinned to the Start menu, _____ to find it in the list of installed
    7·1 answer
  • Which is an example of synchronous communication?
    9·2 answers
  • ________models software in terms similar to those that people use to describe real- world objects.
    6·1 answer
  • 2.3.4 CodeHS HTML Word Definitions
    10·1 answer
  • Select the correct navigational path to set the name for a cell range.
    15·2 answers
  • Write any two rules for writing algorithm​
    10·1 answer
  • Give 3 reasons why it is believed that smart phones precent us from communicating face to face.give three reasons why it is beli
    8·1 answer
  • To what extent do preexisting personal biases affect representation in new media
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!