From bcb73f3a1309efb28b4124da1dd3318cc4f85b3e Mon Sep 17 00:00:00 2001 From: mayfff <84086579+mayfff@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:13:12 +0200 Subject: [PATCH] Create FirstLab.java --- .../lab1/FirstLab.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/_12_Закревський_Данило_Сергійович/lab1/FirstLab.java diff --git a/src/_12_Закревський_Данило_Сергійович/lab1/FirstLab.java b/src/_12_Закревський_Данило_Сергійович/lab1/FirstLab.java new file mode 100644 index 0000000..9dee093 --- /dev/null +++ b/src/_12_Закревський_Данило_Сергійович/lab1/FirstLab.java @@ -0,0 +1,30 @@ +import java.util.Scanner; + +public class FirstLab { + + public static void main(String[] args) { + Scanner scn = new Scanner(System.in); + final int C = 0; + double S = 0.0; + System.out.print("Enter a: "); + int a = scn.nextInt(); + System.out.print("Enter b: "); + int b = scn.nextInt(); + System.out.print("Enter n: "); + int n = scn.nextInt(); + System.out.print("Enter m: "); + int m = scn.nextInt(); + if ((a <= 0 & n >= 0) | (b <= 0 & m >= 0)){ + System.out.println("Division by 0!"); + } else { + for (char i = (char) a; i <= n; i++) { + for(char j = (char) b; j <= m; j++) { + S += (double) (i % j) / (i + C); + } + } + System.out.printf("Result - %.3f", S); + } + + scn.close(); + } +}