Write a program that first get the value of a positive integer N (where N> 0)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that first get the value of a positive integer N (where N> 0) from the user. It then computes the double number 2 using the following series. Use a looping structure. All divisions are real, floating point divisions. Z=1+(1/2) + (1/3) + (1/4)+...+(1/N) Sample Session Microsoft Visual Studio Debug Console Enter a positive integer: 10 - 2.92897 Problem 2: Write a program that asks the user to input a positive integer x. The program then computes and displays the value. of the floating point number 2 using the following formula: (All divisions should be real, floating point divisions). Use afor looping structure. 2 = Microsoft Visual Studio Debug Console Enter a positive integer: 2 Z 3.53804 1 1 x x+1 x+2 Note that the program should NOT allow the user to input a value <=0 Sample Session 1: Sample Session 2: GN Microsoft Visual Studio Debug Console Enter a positive integer: -2 Invalid input ++ 1 x + 50 GS Microsoft Visual Studio Debug Console Enter two integers: 3 7 Sum 25 Problem 3: Write a program that asks the user to enter the valuesfor two positive integers Nl and N2. It is assumed that user will enter those values such that N2 is always greater than NI. The program then computes and prints the sum of all the integers present between NI and N2 (with both NI and N2 included). Your program must use a forlooping structure For example, if N1-3 and N2-7, then the sum printed will be 25 (ie, -3+4+5+6+7). Sample Session 1: Problem 4: Write a program that generates a table showing the angle 8 (in radians), from 0 to 2m in the step of 1/4, and the corresponding values for sin(8) and cos). Moreover, prove the identity that sin²(8) + cos²(8) 1 for each value of 8. Hint: Declare and initialize as const double PI- 3.14159; Use a for loop with theta (angle) varying from 0 to 2*, with end of iteration expression incrementing theta by/4. Use sin(theta) and costheta) functions from <math> library to get the values of sin(theta) and costheta), respectively. The angle theta should be in radians. Use cout.precision (5); cout <<scientific; before printing the numbers to form at the output as shown in the sample. Sample Output: (Your output may not be perfectly aligned within columns) EA Microsoft Visual Studio Debug Console sin(theta) theta 0.000000+00 7.85397e-01 0.000000+00 7.071060-01 1.570790+00 1.000000+00 2.35619e+00 7.071080-01 3.141590+00 2.653590-06 3.926990+00 4.712390+00 5.49778e+00 6.283180+00 cos(theta) 1.000000+00 7.07107e-01 1.32679e-06 -7.071050-01 -1.000000+00 -7.071040-01 -7.071090-01 -1.000000+00 -3.980380-06 -7.071100-01 7.071030-01 -5.307180-06 1.000000+00 sin2(theta) + cos2(theta) 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 A Write a program that first get the value of a positive integer N (where N> 0) from the user. It then computes the double number 2 using the following series. Use a looping structure. All divisions are real, floating point divisions. Z=1+(1/2) + (1/3) + (1/4)+...+(1/N) Sample Session Microsoft Visual Studio Debug Console Enter a positive integer: 10 - 2.92897 Problem 2: Write a program that asks the user to input a positive integer x. The program then computes and displays the value. of the floating point number 2 using the following formula: (All divisions should be real, floating point divisions). Use afor looping structure. 2 = Microsoft Visual Studio Debug Console Enter a positive integer: 2 Z 3.53804 1 1 x x+1 x+2 Note that the program should NOT allow the user to input a value <=0 Sample Session 1: Sample Session 2: GN Microsoft Visual Studio Debug Console Enter a positive integer: -2 Invalid input ++ 1 x + 50 GS Microsoft Visual Studio Debug Console Enter two integers: 3 7 Sum 25 Problem 3: Write a program that asks the user to enter the valuesfor two positive integers Nl and N2. It is assumed that user will enter those values such that N2 is always greater than NI. The program then computes and prints the sum of all the integers present between NI and N2 (with both NI and N2 included). Your program must use a forlooping structure For example, if N1-3 and N2-7, then the sum printed will be 25 (ie, -3+4+5+6+7). Sample Session 1: Problem 4: Write a program that generates a table showing the angle 8 (in radians), from 0 to 2m in the step of 1/4, and the corresponding values for sin(8) and cos). Moreover, prove the identity that sin²(8) + cos²(8) 1 for each value of 8. Hint: Declare and initialize as const double PI- 3.14159; Use a for loop with theta (angle) varying from 0 to 2*, with end of iteration expression incrementing theta by/4. Use sin(theta) and costheta) functions from <math> library to get the values of sin(theta) and costheta), respectively. The angle theta should be in radians. Use cout.precision (5); cout <<scientific; before printing the numbers to form at the output as shown in the sample. Sample Output: (Your output may not be perfectly aligned within columns) EA Microsoft Visual Studio Debug Console sin(theta) theta 0.000000+00 7.85397e-01 0.000000+00 7.071060-01 1.570790+00 1.000000+00 2.35619e+00 7.071080-01 3.141590+00 2.653590-06 3.926990+00 4.712390+00 5.49778e+00 6.283180+00 cos(theta) 1.000000+00 7.07107e-01 1.32679e-06 -7.071050-01 -1.000000+00 -7.071040-01 -7.071090-01 -1.000000+00 -3.980380-06 -7.071100-01 7.071030-01 -5.307180-06 1.000000+00 sin2(theta) + cos2(theta) 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 1.000000+00 A
Expert Answer:
Answer rating: 100% (QA)
Problem 1 As per the Question i used looping structures to complete i have wrote this problem in pyt... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Discuss the strategies for scaling databases to handle large volumes of data and high transaction rates. Explain the concepts of sharding, replication, and clustering. Describe how databases achieve...
-
Imagine that Costco has $500,000 of sales (selling 31,250 units) in August and has a contribution margin ratio of 40% and fixed costs of $20,000. If sales in units increase by 15% in September, what...
-
Ivanhoe Company incurred research and development costs of $ 9 0 0 0 0 to develop a patent, and legal fees of $ 3 0 0 0 0 to register the patent. The patent has a legal life of 2 0 years and a useful...
-
XYZ purchased an equipment worth of $150,000 including insurance cost $30,000 and duty cost $20,000 on May 15, 2018. They have decided to capitalize the $35,000 installation charge instead of $20,000...
-
Write a persuasive analysis of a literary work; Identify the theme and structure of each literary selection as well as the significant characteristics or elements of each genre and evaluate the...
-
You are the key user of the firm's accounts receivable system and have been asked to lead an internal audit of this system. Outline the steps you would take to complete the audit. Identify specific...
-
Fullerton Corporation initially records its sales at amounts that exclude any related excise and sales taxes. During June, Fullerton recorded total sales of \(\$ 700,000\). An analysis of June sales...
-
Suppose that the sunken barge in United States v. Carroll Towing Co. and its cargo are worth $100,000. Assume that the probability that the barge would break loose if the bargee is not present equals...
-
cycle time: Mixing ingredients; 5 minutes / cake Baking; 6 minutes / cake Packaging; 2 minutes / cake The maximum production rate for this bakery is: 30 cakes/hour 12 cakes/hour 10 cakes/hour
-
James Silva is a management accountant at Kleebler - Olson, where he is in charge of their investment portfolio. James worked with a data scientist to develop a model that predicts how a given loan...
-
You just won the lottery! You can either take half of the $65,000,000 in a lump sum today OR you can take yearly payments of $3,000,000 for 25 years (at the beginning of each year). Which option has...
-
Inventory records for Eliza Company revealed the following: Date Transaction March 1 Beginning Inventory March 10 Purchase March 16 Purchase March 23 Purchase Number of Units Unit Cost 1,080 $ 7.13...
-
Q1 Canada should adopt American-style "right -to-work" laws ? Argument Summary in favour or Against.
-
How does International Benefits works ? example of some countries?
-
Develop an evaluation plan utilizing the theories including identification of an appropriate external market and benchmarks for salary comparison data and analysis, on the job position of Strategic...
-
Some companies have moved away from individual commission-based incentive plans to team-oriented incentive plans. How do you think these changes will affect these companies? Which of these plans...
-
Are environmental laws relevant for the tort of private nuisance ? provide some examples What are the elements of the tort of private nuisance?
-
State whether each of the following will increase or decrease the power of a one-way between-subjects ANOVA. (a) The effect size increases. (b) Mean square error decreases. (c) Mean square between...
-
Consider a class Time that represents a time of day. It has attributes for the hour and minute. The hour value ranges from 0 to 23, where the range 0 to 11 represents a time before noon. The minute...
-
ELIZA was a program written in 1966 that parodied a psychotherapist session. The user typed sentences and the program used those words to compose a question. Create a simple GUI application based on...
-
Revise the method selectionSort that appears in Listing 7.10 so that it calls the method described in the previous exercise. Listing 7.10 /** Class for sorting an array of base type int from smallest...
-
Find number of stages needed for a countercurrent extractor if 10 \(\mathrm{kmol} / \mathrm{h}\) feed that is \(10 \mathrm{~mol} \% \mathrm{CCl}_{4}\) and \(90 \mathrm{~mol} \%\) acetic acid is...
-
The horizontal settler calculation in Example 13-7 was done for a settler diameter of \(\mathrm{D}_{\mathrm{s}}=1.023 \mathrm{~m}\) with the dispersion band assumed to be at the center of the circle....
-
Suppose in Example 13-7 that we decide to build the settler with a diameter of \(1.0 \mathrm{~m}\) and a length of \(4.0 \mathrm{~m}\). What safety factor are we employing? Example 13-7 Design a...
Study smarter with the SolutionInn App