Advertisement
CoineTre

JF-ExcMethods05.AddSubtract

Feb 12th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exc5AddSubtract {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int first = Integer.parseInt(scanner.nextLine());
  7.         int second = Integer.parseInt(scanner.nextLine());
  8.         int third = Integer.parseInt(scanner.nextLine());
  9.         System.out.println(getResult(first, second, third));
  10.     }
  11.  
  12.     private static int getResult(int first, int second, int third) {
  13.         return ((first+ second)-third);
  14.     }
  15.  
  16. }
  17.  
  18. //You will receive 3 integers. Write a method sum to get the sum of the first
  19. // two integers and subtract method that subtracts the third integer
  20. // from the result from the sum method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement