veronikaaa86

09. Calculations

May 13th, 2021 (edited)
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Calculations {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int numOne = Integer.parseInt(scanner.nextLine());
  10.         int numTwo = Integer.parseInt(scanner.nextLine());
  11.  
  12. //        The sum is: 26177package com.company;
  13.  
  14. import java.util.Scanner;
  15.  
  16. public class Calculations {
  17.     public static void main(String[] args) {
  18.         Scanner scanner = new Scanner(System.in);
  19.  
  20.         int numOne = Integer.parseInt(scanner.nextLine());
  21.         int numTwo = Integer.parseInt(scanner.nextLine());
  22.  
  23. //        The sum is: 26177
  24. //        The difference is: 26139
  25. //        The product is: 497002
  26. //        The average is: 13088.500000
  27.  
  28.         System.out.println("The sum is: " + (numOne + numTwo));
  29.         // Принтираме резултата, като изчисляваме разликата, използвайки Math.abs -> намиране на абсолютна стойност на число или разстоянието от цифрата до нулата (винаги връща положително число)
  30.         System.out.println("The difference is: " + Math.abs(numOne - numTwo));
  31.         System.out.println("The product is: " + numOne * numTwo);
  32.         System.out.println("The sum is: " + (numOne + numTwo) / 2);
  33.  
  34.     }
  35. }
  36.  
  37. //        The difference is: 26139
  38. //        The product is: 497002
  39. //        The average is: 13088.500000
  40.  
  41.         System.out.println("The sum is: " + (numOne + numTwo));
  42.         System.out.println("The difference is: " + Math.abs(numOne - numTwo));
  43.         System.out.println("The product is: " + numOne * numTwo);
  44.         System.out.println("The sum is: " + (numOne + numTwo) / 2);
  45.  
  46.     }
  47. }
  48.  
Add Comment
Please, Sign In to add comment