(This is for Java)
I have to write a code that takes three numbers entered from the
keyboard and adds the three numbers.
But for this, I need to use the sum() method
SOURCE CODE IN JAVA:
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int x = in.nextInt();
System.out.print("Input second number: ");
int y = in.nextInt();
System.out.print("Input third number: ");
int z = in.nextInt();
int ans = Integer.sum(Integer.sum(x,y),z);
System.out.println("Sum of three numbers is : " + ans);
}
}
Sample INPUT & OUTPUT:
Please give me a thumbs up if you like the answer. Thanks in advance.
Get Answers For Free
Most questions answered within 1 hours.