Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class SumTwoNumbers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner (System.in);
- int startSmallNumberInput=Integer.parseInt(scanner.nextLine());
- int finalBigNumberInput=Integer.parseInt(scanner.nextLine());
- int magicNumber=Integer.parseInt(scanner.nextLine());
- int count=0;
- for(int small=startSmallNumberInput;small<=finalBigNumberInput;small++){
- for(int big=startSmallNumberInput;big<=finalBigNumberInput;big++){
- count++;
- if(small+big==magicNumber){
- System.out.printf("Combination N:%d (%d + %d = %d)",count,small,big,magicNumber);
- return;
- }
- }
- }
- System.out.printf("%d combinations - neither equals %d",count,magicNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement