Answer to Question #3473 in Java | JSP | JSF for Y mukundareddy

Question #3473
1. Write a program to sum two numbers, by defining your own function called public static void sum(int a, int b);
1
Expert's answer
2011-08-07T07:14:41-0400
public class Task4
{
public static void main(String[] args)
{
& System.out.println("5 + 2 = " + sum(5, 2));
& System.out.println("0 + 0 = " + sum(0, 0));
& System.out.println("-90807 + 14444 = " + sum(-90807, 14444));
}

// This function cannot be 'void' because it would return a result
public static int sum(int a, int b)
{
& return a + b;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS