The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Need help with a java program to create random values as input for a different program that needs to be tested before it is implemented by your boss. Your boss asks you to have it create some statistics for you at the same time. You realize you are going to have to do some work with random numbers and the math class. You also know that you are going to be working with a system that sometimes has different inputs into the jobs it does...so that means you are going to have to read overloaded methods...and the best way to review something is to write a test program with it, so you decide to work it in. Create a program with the following requirements:
I. It must have 4 randomly generated numbers in main. These numbers should have values in the range 1-10.
I.a. Make sure to print their values for the user, this is the way to test and see what they are.
II. You must write a custom method to find the AVERAGE of 4 numbers, and write an overloaded version of the same method (with the same name...it’s an overloaded method) that takes only 3 numbers and a string value as parameters. The first version should just return the average of 4 numbers. The second one should return the average of 3 numbers and print a message saying "Finding the average of all except " + [value of the string passed in]
II.a Write test code to call each method from main. Test the first one with all four random numbers and report the results. Then test the second one passing the first three random numbers and pass the message "the fourth random number" (to tell that it is the fourth one that is not in the set when it is printed.)
you are writing an overloaded method that takes 4 numbers as parameters..and a second version of the same method that takes 3 numbers and a string. It should include both of these methods [It has to be assigned and have 2 methods of the same name and what was being done here. It's an exercise to get you to write an overloaded method.]
III. Use the Math class functions to report the smallest value of your four numbers. (You might want to write a separate method to do this. The min method can only check two of them at a time in this language. You will have to do a series of them in some way to find the minimum of all four and return it.)
IV. For the end you need to send a random message to the user at the end. It should be one of the following: "Thank you for playing", "Have a Nice Day", "Goodbye Wally World", or "So Long Folks"
You can't make random strings...but you know there are 4 of them...and you can make a random integer for 1-4. This sounds like a job for a random number and a nested IF or a Case Statement
-----------