Write a C++ program that performs the following (see the Appendix for useful functions): (a) Prompt the user to enter two positive integers n and m (you are not required to handle the case when n or m are not positive), and a real number z (z is real, i.e it can be a decimal and it can be negative). Read the values entered by the user and store them in variables of appropriate data types. (b) Ask the user to enter one of two choices: 'd' or 'D' for deterministic sum 'r' or 'R' for random product o If the user's choice is a deterministic sum, then compute and print the following summation (where n, m, and z are the values entered in part a): m+n k det sum = + z xk k=n o Otherwise, if the choice is a random product, then compute and print the following random product (where n, m, and z are the values entered in part a, and r is a random decimal number between 0 and 1 inclusive): m+n I[a.1+ r) rand_prod = z x k=n Note: Notice that r depends on k, this means that you need to generate a new random decimal in the range [0,1] for each k. o If the user enters an invalid choice (any character other than 'd', 'D', 'r', or 'R'), print an error message. (c) Update the program to allow the user to repeat (enter new values of n, m, and z, and a new choice), and display the new results for the new inputs. Your program will never stop (it will keep asking the user for new input after each run)
Write a C++ program that performs the following (see the Appendix for useful functions): (a) Prompt the user to enter two positive integers n and m (you are not required to handle the case when n or m are not positive), and a real number z (z is real, i.e it can be a decimal and it can be negative). Read the values entered by the user and store them in variables of appropriate data types. (b) Ask the user to enter one of two choices: 'd' or 'D' for deterministic sum 'r' or 'R' for random product o If the user's choice is a deterministic sum, then compute and print the following summation (where n, m, and z are the values entered in part a): m+n k det sum = + z xk k=n o Otherwise, if the choice is a random product, then compute and print the following random product (where n, m, and z are the values entered in part a, and r is a random decimal number between 0 and 1 inclusive): m+n I[a.1+ r) rand_prod = z x k=n Note: Notice that r depends on k, this means that you need to generate a new random decimal in the range [0,1] for each k. o If the user enters an invalid choice (any character other than 'd', 'D', 'r', or 'R'), print an error message. (c) Update the program to allow the user to repeat (enter new values of n, m, and z, and a new choice), and display the new results for the new inputs. Your program will never stop (it will keep asking the user for new input after each run)
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
C++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education