Question
Program using JAVA: When your program begins, it should print to the screen an explanation of what the program will do. This explanation should fit
Program using JAVA:
When your program begins, it should print to the screen an explanation of what the program will do. This explanation should fit on one screen (so it cant be too long), but it should communicate the idea of the program. Next, your program that prompts the interactive user for three positive integers: A. An estimate of the maximum number of hairs on a persons head. This positive integer should be obey this inequality: 1000 <= A <= 150000. B. The number of people in a group where you will look for people who have exactly the same number of hairs. This positive integer B should obey this inequality: A < B <= 12000000 C. The number of simulations that your program should run. This positive integer should be <= 100,000. These numbers have to be digits, not names of numbers written with alphabetic characters.The user should not include any punctuation when they enter their numbers. When your program prompts for A, it should make clear what is required. If the user enters anything inappropriate, the program should print a descriptive error message to the screen, and reprompt. This cycle should continue until the interactive user has entered a positive integer in the proper range. Once A has been successfully entered, your program should go through the same process to obtain a positive integer for B from the interactive user, and a positive integer C from the interactive user, where B and C satisfy the requirements above. Smart programmers will have subprograms for fetching positive integers from the interactive user.
Just in case I am being too subtle here, write a subprogram (it may be called a function, it may be called a procedure in the language you choose) that takes input parameters, and returns a positive integer inside the boundaries, a number that the user has entered. Once you have the three numbers, your program should proceed as follows:
Run the simulation below C times, keeping track of data necessary to output the required information below. For each simulation, randomly assign the people in the group a number of hairs on their head. Do this one person at a time. Use a pseudo-random number generator to assign this number, which is an integer from 0 to the number specified as A above. Although it is unrealistic, we will assume that each number in that range is equally likely. (We know this assumption is unrealistic because completely bald people have 0 hairs, and it is likely that 0 will be over-represented in the actual distribution. However, it makes your programming easier, so trust me on this.) Each time a new person is assigned a number of hairs, check to make sure that no two people assigned so far have EXACTLY the same number of hairs. As soon as you detect such a match, note the total number of people assigned to that point, and call that number X. For example, if the first time you find a match is when 564 people have been assigned a random hair count, then X = 564. When one simulation halts, start the next, until C simulations are complete. (Each simulation should eventually halt if you enforced the limits for B. Can you see why?) When all the simulations are complete, print the following information to the screen and wait for the interactive user to push ENTER before halting the problem. Each number given should be labelled (with an explanation, not just a varilable name) so that the interactive user will know exactly what the number means: 1. A 2. B 3. C 4. The minimum X that occurred over all simulations. 5. The maximum X that occurred over all simulations 6. The average X that occurred over all simulations Something to ponder: clearly you have to keep track of the different X values until you get a match. You will need a data structure to hold those numbers. How large does that data structure have to be? No matter what programming language you eventually use, start the source code for your program with an extensive opening comment. The first line of that opening comment must describe which programming language you are using. (More about that below.)
In addition to the extensive opening comment, internal comments should explain important data structures where they are declared and/or used, delineate large sections of code (paragraphing comments), and clarify anything clever or hard to understand in your code. We grade documentation critically, so I recommend that you spend some time on your opening and internal comments. We will test your program by recompiling it, by running it with different inputs and by examining what your program does.
Please read carefully and then respond. I am really looking forward for the help. Thank you
Step 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