Home /
Expert Answers /
Computer Science /
question-3-4-mark-use-method-overloading-to-design-a-program-to-ask-the-user-to-add-2-or-3-numbe-pa205
(Solved):
Question 3 (4 mark) Use method overloading to design a program to ask the user to add 2 or 3 numbe ...
Question 3 (4 mark) Use method overloading to design a program to ask the user to add 2 or 3 numbers together. First, generate a random number between 0 and 1, and if it is equal to 0 , ask the user to add 2 numbers together, and if it is equal to 1 , ask them to add 3 numbers together.| REQUIREMENTS - The user input is always of the correct type (input verification is not required). - All numbers and computation results are all assumed to be in int type. - The random numbers used are to be created in the "main" and passed to the overloaded method. - The method calcaddition () is to be overloaded. The first one will receive 2 integers and print out the question, ask the user to enter the result, and print a message saying if the result is correct or not. The second one will do the same but with 3 numbers: it will receive 3 integers and print out the question, ask the user to enter the result, and print a message saying if the result is correct or not. - The method main () is to first generate a random number between 0 and 1 (inclusive), and then call the appropriate calcAddition () method and pass either 2 or 3 random numbers between 10 and 50 ( 2 random numbers if the initial random number was 0 , and 3 random numbers if the initial random number was 1 ). - Your code must produce the exact same output as shown below (the text in bold indicates the user input).