Computer Science Assignment

Read Complete Research Material



Computer Science Assignment

Computer Science Assignment

Java Source Code for Adding Two Numbers after taking Input from the User

public class AdditionTest {

public static void main(String args) {

Scanner scanner = new Scanner(System.in);

System.err.println("Please enter first number to add : ");

int number = scanner.nextInt();

System.out.println("Enter second number to add :");

int num = scanner.nextInt();

int result = add(number, num);

System.out.printf(" Addition of numbers %d and %d is %d %n", number, num, result);

}

public static int add(int number, int num){

return number + num;

}

}

Output of the Program

Please enter first number to add:

15

Enter second number to add:

20

Addition of numbers 15 and 20 ...