Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

Java Exercises: Accepts three integers and check whether sum of the first two given integers is greater than third one

Java Basic: Exercise-247 with Solution

Write a Java program which accepts three integers and check whether sum of the first two given integers is greater than third one. Three integers are in the interval [-231, 231 ].

Sample Solution:

Java Code:

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("Check whether (a + b) is greater than c?");
            System.out.println(a + b > c);
       }
}

Sample Output:

Input three integers (a,b,c):
5 8 9
Check whether (a + b) is greater than c?
true

Pictorial Presentation:

Java Basic Exercises: Accepts three integers and check whether sum of the first two given integers is greater than third one.

Flowchart:

Flowchart: Accepts three integers and check whether sum of the first two given integers is greater than third one.

Java Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a Java program to convert 3 digits positive number in above format. For example, 234 should be output as BBSSS1234 because it has 2 "hundreds", 3 "ten", and 4 of the ones.
Next: Write a Java program to check if each letter of a given word is less than the one before it.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Java: Tips of the Day

How to sort an ArrayList?

Collections.sort(testList);
Collections.reverse(testList);

That will do what you want. Remember to import Collections though!

Ref: https://bit.ly/32urdSe