Question
Problem 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
Problem 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).
Problem 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; in C++, you might use a std::string or a char*; and so on.)
Problem 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 Boo and the age was given as 11, you would print Your name is Boo and you are 11 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; in C++, you might use std::cin; in C, you might use scanf; and so on.)
Problem 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; in C++, you might use a std::vector or an array; and so on.)
Problem 5
Given a list containing strings of text, determine the longest string (i.e., the string that contains the largest number of characters).
Problem 6
Read input from a user that is intended to be a consist of a license number (such as a driver's license number). If the input is not a valid license number, then ask again, and continue asking until the input is valid.
We'll say, for the purposes of this problem, that a license number must follow these rules in order to be valid:
It must consist only of uppercase letters and digits; anything else (including spaces) would make it invalid.
The first and last characters must be uppercase letters.
There must be at least one digit (and any number of uppercase letters) in between.
By these rules, the following are all valid license numbers: A123B, ABC1DEF, A1B2C3D4E. These would all be invalid: A123, 123B, ABCDEF, A1B2C3D4.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started