Compare commits

..

No commits in common. "8100129706de8cd553c5fa44217785b0f99ad8c5" and "896fc1f4d4d9f0cb53d1c9556e50288dd7b1eceb" have entirely different histories.

5 changed files with 43 additions and 67 deletions

2
.gitignore vendored
View File

@ -0,0 +1,2 @@
Lab 1/Lab_1.class
Lab 2/Lab_2.class

View File

@ -1,64 +0,0 @@
import java.util.Scanner;
public class Lab_1 {
public static void main(String[] args) {
int n, m, a, b;
float s = 0;
Scanner input = new Scanner(System.in);
do {
try {
System.out.print("Enter n: ");
n = input.nextInt();
break;
} catch (Exception e) {
System.out.println("N must be an integer.");
input.nextLine();
}
} while (true);
do {
try {
System.out.print("Enter m: ");
m = input.nextInt();
break;
} catch (Exception e) {
System.out.println("M must be an integer.");
input.nextLine();
}
} while (true);
do {
try {
System.out.print("Enter a: ");
a = input.nextInt();
break;
} catch (Exception e) {
System.out.println("A must be an integer.");
input.nextLine();
}
} while (true);
do {
try {
System.out.print("Enter b: ");
b = input.nextInt();
break;
} catch (Exception e) {
System.out.println("B must be an integer.");
input.nextLine();
}
} while (true);
input.close();
for (int i = a; i <= n; i++) {
for (int j = b; j <= m; j++) {
s += j;
}
}
System.out.println("S = " + s);
}
}

41
Lab 1/Lab_1.java Normal file
View File

@ -0,0 +1,41 @@
import java.util.Scanner;
public class Lab_1 {
public static void main(String[] args) {
int n, m, a, b;
float s = 0;
Scanner input = new Scanner(System.in);
System.out.print("Enter n: ");
n = input.nextInt();
System.out.print("Enter m: ");
m = input.nextInt();
do {
System.out.print("Enter a (can't be above n): ");
a = input.nextInt();
} while (a > n);
do {
System.out.print("Enter b (can't be above m): ");
b = input.nextInt();
} while (b > m);
input.close();
if ((a <= 0) && (n >= 0)) {
System.out.println("Error, division by zero, shutting down!");
System.exit(1);
}
for (int i = a; i < n; i++) {
for (int j = b; j < m; j++) {
s += i * j / i;
}
}
System.out.println("S = " + s);
}
}

View File

@ -1,3 +0,0 @@
fn main() {
}