Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
- */
- import java.util.Scanner;
- public class _06_SumThreeNumbers
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int n1 = Integer.parseInt(console.nextLine());
- int n2 = Integer.parseInt(console.nextLine());
- int n3 = Integer.parseInt(console.nextLine());
- int a = getMin(getMin(n1, n2), n3);
- int c = getMax(getMax(n1, n2), n3);
- int b = 0;
- if (a == n1) {
- b = getMin(n2, n3);
- }
- else if (a == n2) {
- b = getMin(n1, n3);
- }
- else if (a == n3) {
- b = getMin(n1, n2);
- }
- System.out.println((a + b == c) ? (a + " + " + b + " = " + c) : "No");
- }
- public static int getMin(int a, int b) {
- if (a <= b) return a;
- return b;
- }
- public static int getMax(int a, int b) {
- if (a >= b) return a;
- return b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment