Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Calculations {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numOne = Integer.parseInt(scanner.nextLine());
- int numTwo = Integer.parseInt(scanner.nextLine());
- // The sum is: 26177package com.company;
- import java.util.Scanner;
- public class Calculations {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numOne = Integer.parseInt(scanner.nextLine());
- int numTwo = Integer.parseInt(scanner.nextLine());
- // The sum is: 26177
- // The difference is: 26139
- // The product is: 497002
- // The average is: 13088.500000
- System.out.println("The sum is: " + (numOne + numTwo));
- // Принтираме резултата, като изчисляваме разликата, използвайки Math.abs -> намиране на абсолютна стойност на число или разстоянието от цифрата до нулата (винаги връща положително число)
- System.out.println("The difference is: " + Math.abs(numOne - numTwo));
- System.out.println("The product is: " + numOne * numTwo);
- System.out.println("The sum is: " + (numOne + numTwo) / 2);
- }
- }
- // The difference is: 26139
- // The product is: 497002
- // The average is: 13088.500000
- System.out.println("The sum is: " + (numOne + numTwo));
- System.out.println("The difference is: " + Math.abs(numOne - numTwo));
- System.out.println("The product is: " + numOne * numTwo);
- System.out.println("The sum is: " + (numOne + numTwo) / 2);
- }
- }
Add Comment
Please, Sign In to add comment