Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ 1. Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As
C++
1. Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the array only if it is not a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Provide for the "worst case" in which all 20 numbers are different. Use the smallest possible array to solve this problem. Sampe Output Enter 20 integers between 10 and 100: 10 5 Invalid number 20 30 40 50 60 70 80 90 100 110 Invalid number. 10 Duplicate number. 11 22 33 55 66 77 88 99 45 The nonduplicate values are: 10 20 30 40 50 60 70 80 90 100 11 22 33 44 55 66 77 88 99 45 2. Write a program that simulates the rolling of two dice. The program should use and to roll the first die and should use rand again to roll the second die. The sum of the two values should then be calculated. (Note: Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12with being the most frequent sum and 2 and 12 being the least frequent sums.) Figure 7.32 shows the 36 possible combinations of the two dice. Your program should roll the two dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the results in a tabular format. Also, determine if the totals are reasonable lie, there are six ways to roll a 7, so approximately one-sixth of all the rolls should be 7). 1 2 3 4 5 6 2 3 4 5 6 7 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 Sampe Output Sum 2 3 4 5 6 7 8 9 10 11 12 Total Expected 983 2.778% 1918 5.556% 2952 8.33 4138 11.111% 4964 13.889% 5952 16.667% 5062 13.889% 4007 11.111 3071 8.33 2007 5.556% 2.778% Actual 2.7315 5.328% 8.2003 11.494% 13.789% 16.533% 14.061% 11.131 8.531% 5.575% 2.628% 946Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started