Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

New concepts or language features you may use: library functions and random number generation. You always create a separate C++ file for each program

New concepts or language features you may use: library functions and random number generation. You always

New concepts or language features you may use: library functions and random number generation. You always create a separate C++ file for each program you write in lab. 1. Write a C++ program that does the following: a. Create a C++ file with the name problem1.cpp. b. Prompt the user for a positive integer greater than or equal to 10, validating the input until the user enters a positive integer greater than or equal to 10. c. Print a random integer between 1 and the user's integer. Sample run of the program: Enter an integer greater than or equal to 10: 7 Invalid input! Try again: 11 Random integer between 1 and 11 is 9. 2. Write a C++ program that does the following: a. Create a C++ file with the name problem2.cpp. b. Prompt the user for two positive integers, where the difference between the two integers must be at least 10, validating the input until the user enters two positive integers whose difference is at least 10. c. Print a random integer from the range of the smaller integer to the larger integer. Sample run of the program: Enter two positive integers with a difference of at least 10: -1 15 Invalid input! Try again: 59 Invalid input! Try again: 15 39 Random integer between 15 and 39 is 23. 3. Write a C++ program that does the following: a. Create a C++ file with the name problem3.cpp. b. Prompt the user for a positive integer, which is the number of die rolls simulated, printing Not playing games. and terminating the program if the user enters an invalid integer. c. Use a loop to simulate n die rolls, where for each die roll, print the roll number and the simulated die roll value. d. After the last die roll, print the total count of ones rolled. Sample run of the program: Enter the number of die rolls: 5 Roll 1: 2 Roll 2: 3 Roll 3:6 Roll 4: 1 Roll 5: 2 Total number of ones rolled: 1.

Step by Step Solution

3.44 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

1 C program to generate a random integer between 1 and n where n is an integer greater than or equal ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

3 When might constructivist view of self be not relevant and why?

Answered: 1 week ago