(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 Ifthe 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): det sum : (-1)*) zxk 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 I inclusive): rand prod = zx1.1 + ) kan 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++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 1TF: Mark the following statements as true or false: a. To use a predefined function in a program, you...
icon
Related questions
Question
C++ Plz solve as you can quickly
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
enter one of two choices:
"d' or 'D' for deterministic sum
r or 'R' for random product
o Ifthe 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):
det sum =
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):
rand_prod = z x
Note: Notice that r depends on k, this means that you need to generate
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)
Appendix - Useful C++ functions
The following functions/statements are useful to solve the problems of this exam:
• The pow function from the <math.h> library: e.g. pow(x,y) gives the value of x
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 enter one of two choices: "d' or 'D' for deterministic sum r or 'R' for random product o Ifthe 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): det sum = 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): rand_prod = z x Note: Notice that r depends on k, this means that you need to generate 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) Appendix - Useful C++ functions The following functions/statements are useful to solve the problems of this exam: • The pow function from the <math.h> library: e.g. pow(x,y) gives the value of x
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Types of trees
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
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr