S.No: 7 Date: 2022-04-29: Exp. Name: Write A Java Program To Implement Method Overloading
S.No: 7 Date: 2022-04-29: Exp. Name: Write A Java Program To Implement Method Overloading
ID: 20095A0363
Page No:
Aim:
Write a Java program with a class name Addition with the methods add(int, int) ,
add(int, float) , add(float, float) and add(float, double, double) to add values of
different argument types.
Write the main(String[]) method within the class and assume that it will always receive a total of 6 command
line arguments at least, such that the first 2 are int, next 2 are float and the last 2 are of type double.
If the main() is provided with arguments : 1, 2, 1.5f, 2.5f, 1.0, 2.0 then the program should print the output as:
Sum of 1 and 2 : 3
Source Code:
q11266/Addition.java
return a+b;
return a+b;
return a+b;
}
return a+b+c;
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
float c = Float.parseFloat(args[2]);
float d = Float.parseFloat(args[3]);
double e = Double.parseDouble(args[4]);
double f = Double.parseDouble(args[5]);
ID: 20095A0363
Page No:
}
Test Case - 1
User Output
Sum of 2 and 1 : 3
Sum of 5.0 and 3.6 : 8.6
Sum of 1 and 3.6 : 4.6
Sum of 5.0, 9.2 and 5.26 : 19.46