0% found this document useful (0 votes)
23 views4 pages

j11 - Lab Task One

The first code snippet defines a LoginManager class that allows users to log in using either an email or a mobile number, with specific credentials for each method. The second code snippet features an Arrange class that provides sorting methods for both strings and integers, demonstrating bubble sort. Both classes include a main method to test their functionalities.

Uploaded by

Sarathi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

j11 - Lab Task One

The first code snippet defines a LoginManager class that allows users to log in using either an email or a mobile number, with specific credentials for each method. The second code snippet features an Arrange class that provides sorting methods for both strings and integers, demonstrating bubble sort. Both classes include a main method to test their functionalities.

Uploaded by

Sarathi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1)

Code:
class LoginManager {
public void login(String email, String password) {
if (email.equals("[email protected]") && password.equals("sarathi123///")) {
System.out.println("Login successful with email.");
} else {
System.out.println("Login failed with email.");
}
}

public void login(long mobileNumber, String password) {


if (mobileNumber == 1234567890L && password.equals("pass123")) {
System.out.println("Login successful with mobile number.");
} else {
System.out.println("Login failed with mobile number.");
}
}

public static void main(String[] args) {


LoginManager manager = new LoginManager();

manager.login("[email protected]", "sarathi123///");
manager.login("[email protected]", "wrong");

manager.login(1234567890L, "pass123");
manager.login(1111111111L, "wrong");
}
}
Output:
2)
Code:
public class Arrange {
public String[] sort(String[] s) {
for (int i = 0; i < s.length; i++) {
for (int j = i + 1; j < s.length; j++) {
if (s[i].compareTo(s[j]) > 0) {
String temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
}
return s;
}

public int[] sort(int[] a) {


for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
if (a[i] > a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
return a;
}

public static void main(String[] args) {


Arrange obj = new Arrange();

String[] strArr = {"Banana", "Apple", "Mango"};


int[] intArr = {45, 12, 78, 5};

strArr = obj.sort(strArr);
intArr = obj.sort(intArr);

System.out.println("Sorted Strings:");
for (int i = 0; i < strArr.length; i++) {
System.out.println(strArr[i]);
}

System.out.println("Sorted Integers:");
for (int i = 0; i < intArr.length; i++) {
System.out.println(intArr[i]);
}
}
}
Output:

You might also like