Compare commits

...

7 Commits

5 changed files with 67 additions and 43 deletions

2
.gitignore vendored
View File

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

64
Java/Lab 1/Lab_1.java Normal file
View File

@ -0,0 +1,64 @@
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);
}
}

View File

@ -1,41 +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);
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);
}
}

3
Rust/Lab 1/Lab_1.rs Normal file
View File

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