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
zavuch27 [327]
2 years ago
10

Write a program that uses a Scanner object to read two strings from the user’s keyboard. Display each string, along with its wid

th, on two separate lines. Then create a new string by joining the two strings with a space between them. Display the new string and its length on a new separate line.
Computers and Technology
1 answer:
katen-ka-za [31]2 years ago
5 0

Answer:

// here is code in java.

import java.util.*;

class Main

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

       // create 3 string variables

       String st1,st2,st3;

 // scanner object to read input      

Scanner scr=new Scanner(System.in);

System.out.print("enter the first string:");

 // read first string

st1=scr.nextLine();

System.out.print("enter the second string:");

 // read second string

st2=scr.nextLine();

 // print 1st string and its length

System.out.println(st1+" "+st1.length());

 // print 2nd string and its length

System.out.println(st2+" "+st2.length());

 // create 3rd string by joining two string with a space between

st3=st1+" "+st2;

 //// print 3rd string and its length

System.out.println(st3+" "+st3.length());

       

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create three string variables.Read the 1st string and assign it to variable "st1" , read 2nd string and assign it to variable "st2".Find the length of 1st and 2nd  string and then print "st1" & its length.Similarly do it for 2nd string, print  "st2" and its length in a line. Join the first two string with a space in between them. find its length and print the "st3" and its length in a line.

Output:

enter the first string:                                                                                                                                      

hello                                                                                                                                                        

enter the second string:                                                                                                                                      

alex

hello 5                                                                                                                                                      

alex 4                                                                                                                                                        

hello alex 10  

You might be interested in
write a c++ program that takes a string input from the user and removes all characters except numerals also display the number o
Xelga [282]

Answer:

hi

Explanation:

5 0
3 years ago
In the code snippet below, pick which instructions will have pipeline bubbles between them due to hazards.
denpristay [2]

Answer:

b. lw $t4, 4($t0)

c. add $t3, $t5, $t4

Explanation:

Pipeline hazard prevents other instruction from execution while one instruction is already in process. There is pipeline bubbles through which there is break in the structural hazard which preclude data. It helps to stop fetching any new instruction during clock cycle.

7 0
2 years ago
Hey guys do you mind subscribing to my utube BrokenShoe once I hit 40 subs I'm doing a massive giveaway of gift cards ps: also g
luda_lava [24]

Answer:

ok

Explanation:

4 0
2 years ago
What do you mean by algorithm​
Snowcat [4.5K]

A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

7 0
3 years ago
Read 2 more answers
A(n) ________ is a web application that allows users to easily add and edit content on a web page.
seropon [69]
Wiki is a web application that allows users to easily add and edit content on a web page.
5 0
2 years ago
Other questions:
  • what font size should generally be used for the slide title to ensure that it is set off from the content
    6·1 answer
  • What are the most popular/up-and-coming social media applications?
    10·2 answers
  • In a relational database design, all relationships are expressed by ________.
    10·1 answer
  • Which of these are examples of metadata for an audio file of a song recording?
    10·2 answers
  • You can apply several different worksheet themes from which tab?
    10·2 answers
  • What is a set of javascript statements that result in an action?
    15·1 answer
  • MS Excel is a powerful spreadsheet program that helps people with complex mathematical calculations. In what ways could you use
    10·1 answer
  • Adding Page Numbers in the Footer
    15·1 answer
  • 70 point Brainlist to best answer
    15·1 answer
  • eocs can be fixed locations, temporary facilities, or virtual structures with staff participating remotely.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!