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
erica [24]
3 years ago
12

Write a java program that will take 2 String inputs and perform the following operation on them: a) Show length of the strings b

) Concatenate two strings c) Convert those two strings to uppercase.
Computers and Technology
1 answer:
marissa [1.9K]3 years ago
6 0

Answer:

// here is code in java.

import java.util.*;

// class definition

class Solution

{

   // main method of the class

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

{

   try{

 // scanner object to read input from user

Scanner scr=new Scanner(System.in);

 // string variables

String st1,st2;

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

 // read the first string

st1=scr.nextLine();

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

 // read the second string

st2=scr.nextLine();

// part (a)

 // find length of each string

System.out.println("length of first string is: "+st1.length());

System.out.println("length of second string is: "+st2.length());

//part(b)

 // concatenate both the string

System.out.print("after Concatenate both string: ");

System.out.print(st1+st2);

// part(c)

 // convert them to upper case

System.out.println("first string in upper case :"+st1.toUpperCase());

System.out.println("second string in upper case :"+st2.toUpperCase());

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read two strings st1 and st2 with scanner object.In part a, find the length of each string with the help of .length() method and print the length.In part b, concatenate both the string with + operator.In part c, convert each string to upper case with the help of .toUpperCase()  method.

Output:

enter the first string:hello

enter the second string:world!!

length of first string is: 5

length of second string is: 7

after Concatenate both string: hello world!!

first string in upper case :HELLO

second string in upper case :WORLD!!

You might be interested in
Intranets: a. are based on mainframe technology. b. provide the platform on which a firm builds its information systems. c. are
antoniya [11.8K]

Answer: Option (e) is correct

Explanation:

Intranet is the private network that is created for sharing information and data ,handle computing facilities, sharing files etc through internet service within a organization. Members of the company can access this technology for performing activities on the network.

  • Other options are incorrect because numerous networks are not linked ,does not share information outside organization, does not act as information system's base and neither is linked with mainframe technology.
  • Thus,the correct option is option(e).
5 0
3 years ago
Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
larisa [96]

Answer:

<em>The programming language is not stated;</em>

<em>However, the program written in Python is as follows</em>

def solveEquation(x,y,z):

     result = z - y + 2 * x

     print(result)

x = float(input("x = "))

y = float(input("y = "))

z = float(input("z = "))

print(solveEquation(x,y,z))

Explanation:

This line defines the function solveEquation

def solveEquation(x,y,z):

This line calculates the expression in the question

     result = z - y + 2 * x

This line returns the result of the above expression

     print(result)

The next three lines prompts user for x, y and z

x = float(input("x = "))

y = float(input("y = "))

z = float(input("z = "))

This line prints the result of the expression

print(solveEquation(x,y,z))

3 0
2 years ago
Assuming dataFile is an ofstream object associated with a disk file named payroll.dat, which of the following statements would w
svet-max [94.6K]

Answer:

dataFile << salary;

Explanation:

To write salary to a file (payroll.dat) using ofstream, you make use of the following instruction:

<em>ofstream dataFile; </em>

<em>myfile.open ("payroll.dat"); </em>

<em>myfile <<salary; </em>

<em>myfile.close();</em>

<em />

This line creates an instance of ofstream

<em>ofstream dataFile; </em>

This line opens the file payroll.dat

<em>myfile.open ("payroll.dat"); </em>

This is where the exact instruction in the question is done. This writes the value of salary to payroll.dat

<em>myfile <<salary; </em>

This closes the opened file

<em>myfile.close();</em>

<em />

<em />

8 0
2 years ago
While the Internet can be a great resource, the information is not always reliable, as anyone can post information. Select one:
Olin [163]

Answer: True

Explanation: Because anyone can post something and it can be non reliable

7 0
2 years ago
A researcher plans to identify each participant in a certain medical experiment with a code consisting of either a single letter
trapecia [35]

Answer:

5 Letters

Explanation:

So we need 12 distinct codes made of a single letter or a pair of letters.

What would be the least number of letters?

Lets try with 3 letters A, B and C

The possible combinations are: A, B, C, AB, AC, BC

These are 6 codes and we need 12 so lets try more A, B, C and D

The possible combinations are: A, B, C, D, AB, AC, AD, BC, BD, CD

These are 10 codes and we need 12 so lets try more A, B, C, D and E

The possible combinations are:

A, B, C, D, E, AB, AC, AD, AE, BC, BD, BE, CD, CE, DE

Finally we got 15 distinct codes which are more than 12 so the least number of letters needed are 5.

Using formula:

Four letters = 4C1 + 4C2 = 4 + 6 = 10

Five letters = 5C1 + 5C2 = 5 + 10 = 15

5 0
2 years ago
Other questions:
  • What is the block of text at the bottom of the page called?
    7·1 answer
  • Consider an environment in which there is a one-to-one mapping between user-level threads and kernel-level threads that allows o
    7·1 answer
  • A TCP Sender is just about to send a segment of size 100 bytes with sequence number 1234 and ack number 436 in the TCP header. W
    5·1 answer
  • Erewrxdnnefwn q wedsvd
    6·1 answer
  • How do you check to see if the user entered more than one character? Complete the code.
    14·1 answer
  • Use the drop-down menus to complete each sentence.
    8·2 answers
  • Which is the first computer brought in nepal for the census of 2028 B.S​
    6·1 answer
  • Debugging 2.17.3: Debug: The Two Towers Code Hs
    15·1 answer
  • What technology would a bank's website use a scramble information as it is transmitted over the Internet
    7·1 answer
  • Which directory stores the cron configuration file?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!