Solved Exercise Input 3 integers and check whether the sum of the first two are greater than the third one in Java

Codemastr

CEO
Staff member
Administrator
Feb 1, 2019
36
1
238
Write a Java program which accepts three integers and check whether sum of the first two given integers is greater than third one.

This is the code that solves this requirement:

Java:
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Input three integers (a,b,c):");
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();
            System.out.println("Is a+b greater than c?");

            if (a + b > c)
                System.out.println("Yes");
            else
                System.out.println("No");
       }
}
Feel free to ask any questions or post a suggestion.