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)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 13PP
icon
Related questions
Question
C++
II – Numerical Computing
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
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 x k
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):
т+n
rand_prod = z x |(1.1+ 1k)
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)
Transcribed Image Text:II – Numerical Computing 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 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 x k 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): т+n rand_prod = z x |(1.1+ 1k) 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)
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
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