desislava_topuzakova

3. Събиране и изваждане

Feb 13th, 2022
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package Methods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SumAndSubtract_03 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int firstNumber = Integer.parseInt(scanner.nextLine());
  9.         int secondNumber = Integer.parseInt(scanner.nextLine());
  10.         int thirdNumber = Integer.parseInt(scanner.nextLine());
  11.  
  12.         //sum -> връща резултат, който е сумата на две числа
  13.         //subtract -> връща резултата, който е разликата на две числа
  14.  
  15.         int sumOfFirstTwo = sum(firstNumber, secondNumber);
  16.         System.out.println(subtract(sumOfFirstTwo, thirdNumber));
  17.     }
  18.  
  19.     public static int sum (int n1, int n2) {
  20.         return n1 + n2;
  21.     }
  22.  
  23.     public static int subtract (int n1, int n2) {
  24.         return n1 - n2;
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment