1. Write a program that separately prompts the user for a first name and last name and outputs a string containing the following information, in order: a. First letter of the user's name. b. First five letters of the user's last name. c. A random two-digit integer. You must construct the desired string ensuring all characters are lowercase; output the identification string accordingly. Assume the last name contains at least 5 characters. You must use the Random (java.util.Random) class to generate random numbers. As an example, input of Chris Alvin may result in calvin15.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 12SA: 12. What is the output of the following program? (2, 3, 6, 8) #include <iostream> #include...
icon
Related questions
Question

Can you give me two ways to do it 

6:38
al 36%
CS101: Lab #4
Using Classes and Objects Part I
1. Write a program that separately prompts the user for a first name and last name and outputs a
string containing the following information, in order:
а.
First letter of the user's name.
b. First five letters of the user's last name.
A random two-digit integer.
C.
You must construct the desired string ensuring all characters are lowercase; output the
identification string accordingly. Assume the last name contains at least 5 characters. You must use
the Random (java.util.Random) class to generate random numbers.
As an example, input of Chris Alvin may result in calvin15.
2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and
outputs a formatted string (parentheses and dashes included) according to the following rules:
The first 3 digits may not contain an 8 or 9.
b. The second set of three digits must be larger than 100 and less than 888.
a.
You must construct the desired string (using Random class) and then output it accordingly. Until
you are confident in your code, seed the random number generator with 0.
For example, (777) –101-0000 is a valid number.
II
Transcribed Image Text:6:38 al 36% CS101: Lab #4 Using Classes and Objects Part I 1. Write a program that separately prompts the user for a first name and last name and outputs a string containing the following information, in order: а. First letter of the user's name. b. First five letters of the user's last name. A random two-digit integer. C. You must construct the desired string ensuring all characters are lowercase; output the identification string accordingly. Assume the last name contains at least 5 characters. You must use the Random (java.util.Random) class to generate random numbers. As an example, input of Chris Alvin may result in calvin15. 2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and outputs a formatted string (parentheses and dashes included) according to the following rules: The first 3 digits may not contain an 8 or 9. b. The second set of three digits must be larger than 100 and less than 888. a. You must construct the desired string (using Random class) and then output it accordingly. Until you are confident in your code, seed the random number generator with 0. For example, (777) –101-0000 is a valid number. II
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning