Design a class to overload a function sum() as follows:
(a) void sum(int n) – with one int argument that finds the sum of the digits in n.
(b) void sum(Integer n) – with one Integer argument that finds the sum of the digits in n.
Also create the main() method to call the above methods.
Answers
Answered by
1
Answer:
your question is somewhat wrong. I have written the program for the portion(of question) which is correct. Mark me brainliest. Thanks
Explanation:
class over
{
static void sum(int n)
{
int d,sum=0;
d=n%10;
sum=sum + d;
n=n/10;
System.out.println ("Sum=" +sum);
}
Similar questions
Chemistry,
1 month ago
Math,
2 months ago
India Languages,
2 months ago
Social Sciences,
10 months ago