Question: Java write a single function, method, procedure, subroutine, etc., that can be called to solve it. 1 Given two numbers, representing the width and the

Java

write a single function, method, procedure, subroutine, etc., that can be called to solve it.

1

Given two numbers, representing the width and the height of a right triangle, calculate the perimeter of the triangle (i.e., the sum of the lengths of all three of its sides).

2

Given two strings of text, calculate their concatenation and return it as a separate string of text. The concatenation of two strings is a string that contains all of the characters in the first string, followed by all of the characters in the second. For example, the concatenation of boo and lean is boolean.

(Whenever these problems refer to a "string of text," I'm referring to a sequence of individual characters. Choose an implementation that is appropriate for the language you chose. For example, in Java, you would use a String)

3

Separately read two pieces of input from a user, which are intended to be both a name and an age (in years). Afterward, print the output Your name is XXX and you are YYY years old, where XXX is the name and YYY is the number of years old. So, for example, if the name was given as Tom and the age was given as 22, you would print Your name is Tom and you are 22 years old. Note, too, that you should finish that sentence with 1 year old instead of 1 years old if the age is 1.

(Whenever these problems refer to reading input from a user, you'll need to handle that in a way that is appropriate for the language you chose. For example, in Java, you might use a Scanner.)

4

Given a list of numbers, compute its sum.

(Whenever these problems refer to a "list", I'm referring to a sequence that may have an arbitrary number of values in it. Choose an implementation that is appropriate for the language you chose. For example, in Java, you might use an ArrayList or an array.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!