JAVA 12


Using Method Overloading

In the followingexercises, you design and write Java programs that use method overloading.

1a. Design a program that has five definitions of the dataOut. with each having a different signature.  The signatures for the five method definitions are:

·         char, String, int, double

·         String,  int,  double,  char

·         int,  double

·         char,  String

·         char,  int

Within the method main, call each dataOut. method using an appropriate list of arguments chosen from four variables that are declared in main:

·         A char variable named letter, assigned the value ‘a’

·         A String named name, assigned “Hello”

·         An int variable named number, assigned the value 5

·         A double variable named value, assigned the value 6.25

Be sure to include comments and display the results to the user.

Following is a copy of the screen results that might appear after running your page.

You called dataOut with

·         the character Hello a,

·         the string Hello,

·         the integer number 5,

·         and the double number 6.25

 

You called dataOut with

·         the string Hello,

·         the integer number 5,

·         the double number 6.25,

·         and the character a

You called dataOut with

·         the integer number 5

·         and the double number 6.25

You called dataOut with

·         the character a

·         and the string Hello

You called dataOut with

·         the character a

·         and the integer number 5

Write your design.  THE DESIGN SHOULD BE A LIST OF JAVA COMMENTS WITHOUT ANY CODE

1b. Write a Java program based on the design you created in Exercise 1a.  Save the program as PrintData.java. Compile, run, and test the program.  Copy the instructions and output that are displayed, and paste them in a block comment at the end of your program.

    • 12 years ago
    complete solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      using_method_overloading_answer.docx