Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a package named Q2. Create a java class named Task2 which will include the driver method, header and footer methods you defined in question

image text in transcribed
image text in transcribed
Create a package named Q2. Create a java class named Task2 which will include the driver method, header and footer methods you defined in question 1 and five overloaded methods. Define (copy-paste from question 1) the header and footer methods printHcader() and printFooter(). Define the overloaded public static method called sumValues() with the following specs: The first method will accept two strings as argument and return the added strings. The second one will accept two real numbers as argument and return the added result when called The third one will accept two characters as argument, and return the resultant character after adding those two, when called. The fourth one will accept one character as argument, and after being called, will generate a second character between 'E' and 'K' inclusive by calling Math.random() method from inside it. It will then print the generated character from inside this method, and after that add the generated character with the first one (received via argument). Finally, the resultant character will be returned to the called method. (Hint: For Math.random() method with examples See Slide #139 and 141 from Unit 2, and slide #48 and 49 from Unit 3) The fifth one will accept one integer number as argument, and after being called, will generate a second integer number between 5 and 15 inclusive by calling Math.random() method from inside it, It will then print the generated number from inside this method, and after that add the generated number with the first one (received via argument). Finally, the resultant integer number will be returned to the called method. (Hint: For Math.random() method with examples See Slide #139 and 141 from Unit 2) Note: All the above methods should be public and static methods with the name sumValues. Based on the specifications outlined above you pick up the appropriate formal parameters and return types for these overloaded methods. Complete the driver method with the following specs in sequence as outlined below: Print the custom header message with the appropriate question number as argument by calling the header method. oCall the sum Values() method to add the numbers 2.5 and 13.6, and then print their sum with two decimal places from the driver method using printf statement. oCall the sum Values() method to add the characters 'a' and 'd', and print the resultant character from the driver method using printf() statement. o Prompt the user to input a name using Scanner reference variable. o Call the sumValues() method to add the strings "I am" and the user-entered name, and print the added strings from the driver method using printf() statement. o Using the same Scanner reference-variable, prompt the user to input any character (see slide #93, unit 2). (Watch out: If you used nextLinc() method before this prompt, you have to clear the input buffer before asking for this; sec slide #94 - 96, Unit2) o Call the sumValues() method and pass the user entered character; print the randomly generated character from inside the sumValues() method, and then add this with the one received via the formal parameter. Finally print the resultant character from the driver method using printf() statement. o Using the same Scanner reference-variable, prompt the user to input any integer. o Call the sum Values() method and pass the user entered integer; print the randomly generated integer number from inside the sumValues() method, and then add this with the one received via the formal parameter. Finally print the resultant integer number from the driver method using printf() statement. o Print the custom footer message by calling the footer method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago