7 665
مشترکین
-824 ساعت
-407 روز
+2030 روز
آرشیو پست ها
+1
CTS 2PM SLOT ✅✅
SLOT-1
CONTACT FOR ANY EXAM HELP @MLCODER2
+2
HASHEDIN BY DELOITTE EXAM DONE SUCCESSFULLY ✅✅✅
ALL CODES ✅✅
Contact: @MLCDER2
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int p = sc.nextInt();
if (p <= 0 p > 100) {
System.out.println("Invalid number of rows. Exiting program.");
return;
}
int q = sc.nextInt();
if (q <= 0 q > 100) {
System.out.println("Invalid number of columns. Exiting program.");
return;
}
int[][] matrix = new int[p][q];
for (int i = 0; i < p; i++) {
for (int j = 0; j < q; j++) {
matrix[i][j] = sc.nextInt();
}
}
int C = sc.nextInt();
if (C < 1 || C > q) {
System.out.println("Invalid column number. Exiting program.");
return;
}
sc.close();
int minElement = Integer.MAX_VALUE;
int columnIndex = C - 1;
for (int i = 0; i < p; i++) {
minElement = Math.min(minElement, matrix[i][columnIndex]);
}
System.out.println("The minimum element in column " + C + " is: " + minElement);
}
}
#Matrix_Column_Minimum_Finder
package Learn.com;
import java.util.Scanner;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int L = sc.nextInt();
int U = sc.nextInt();
sc.close();
if (L < 0 U < L U > 100) {
System.out.println("Invalid input! Please ensure 0 <= L <= U <= 100");
return;
}
Map<Integer, Integer> freqMap = new HashMap<>();
for (int i = L; i <= U; i++) {
for (int j = i + 1; j <= U; j++) {
int diff = Math.abs(i - j);
freqMap.put(diff, freqMap.getOrDefault(diff, 0) + 1);
}
}
int maxFrequency = 0;
int mostFrequentDiff = 0;
for (Map.Entry<Integer, Integer> entry : freqMap.entrySet()) {
if (entry.getValue() > maxFrequency) {
maxFrequency = entry.getValue();
mostFrequentDiff = entry.getKey();
}
}
System.out.println("Marathon Winner: " + mostFrequentDiff + " minutes (occurring " + maxFrequency + " times)");
}
}
#Marthon_Winner_Finder
IBM OFFLINE CODING ✅✅
PYTHON 7/7 CASES PASSED ✅
JAVA 5/7 CASES PASSED WITH THE DRIVER CODE NOT CONFIGURED PROPERLY ✅
case "part time employee salary":
System.out.println(partTimeEmployee.getSalary());
break;
case "update full time employee":
String attrFullTime = scanner.nextLine().trim();
String valueFullTime = scanner.nextLine().trim();
fullTimeEmployee.updateAttribute(attrFullTime, valueFullTime);
break;
case "update part time employee":
String attrPartTime = scanner.nextLine().trim();
String valuePartTime = scanner.nextLine().trim();
partTimeEmployee.updateAttribute(attrPartTime, valuePartTime);
break;
case "retrieve full time employee":
String retrieveFullTimeAttr = scanner.nextLine().trim();
System.out.println(fullTimeEmployee.retrieveAttribute(retrieveFullTimeAttr));
break;
case "retrieve part time employee":
String retrievePartTimeAttr = scanner.nextLine().trim();
System.out.println(partTimeEmployee.retrieveAttribute(retrievePartTimeAttr));
break;
default:
System.out.println("Invalid command.");
}
}
scanner.close();
}
}
#EMPLOYEE_MANAGEMENT ✅✅✅
import java.util.*;
abstract class Employee {
protected int id;
protected String name;
protected float baseSalary;
public Employee(int id, String name, float baseSalary) {
this.id = id;
this.name = name;
this.baseSalary = baseSalary;
}
public abstract float getSalary();
public void updateAttribute(String attribute, String value) {
switch (attribute.toLowerCase()) {
case "id":
this.id = Integer.parseInt(value);
System.out.println("Updated id to: " + this.id);
break;
case "name":
this.name = value;
System.out.println("Updated name to: " + this.name);
break;
case "base salary":
this.baseSalary = Float.parseFloat(value);
System.out.println("Updated base salary to: " + this.baseSalary);
break;
default:
System.out.println("Invalid attribute for employee: " + attribute);
}
}
public String retrieveAttribute(String attribute) {
switch (attribute.toLowerCase()) {
case "id":
return String.valueOf(id);
case "name":
return name;
case "base salary":
return String.valueOf(baseSalary);
default:
return "Invalid attribute for employee: " + attribute;
}
}
}
class FullTimeEmployee extends Employee {
private float bonus;
public FullTimeEmployee(int id, String name, float baseSalary, float bonus) {
super(id, name, baseSalary);
this.bonus = bonus;
}
@Override
public float getSalary() {
return baseSalary + bonus;
}
@Override
public void updateAttribute(String attribute, String value) {
if (attribute.equalsIgnoreCase("bonus")) {
this.bonus = Float.parseFloat(value);
System.out.println("Updated bonus to: " + this.bonus);
} else {
super.updateAttribute(attribute, value);
}
}
@Override
public String retrieveAttribute(String attribute) {
if (attribute.equalsIgnoreCase("bonus")) {
return String.valueOf(bonus);
} else {
return super.retrieveAttribute(attribute);
}
}
}
class PartTimeEmployee extends Employee {
private float hourlyRate;
public PartTimeEmployee(int id, String name, float baseSalary, float hourlyRate) {
super(id, name, baseSalary);
this.hourlyRate = hourlyRate;
}
@Override
public float getSalary() {
return baseSalary * hourlyRate;
}
@Override
public void updateAttribute(String attribute, String value) {
if (attribute.equalsIgnoreCase("hourly rate")) {
this.hourlyRate = Float.parseFloat(value);
System.out.println("Updated hourly rate to: " + this.hourlyRate);
} else {
super.updateAttribute(attribute, value);
}
}
@Override
public String retrieveAttribute(String attribute) {
if (attribute.equalsIgnoreCase("hourly rate")) {
return String.valueOf(hourlyRate);
} else {
return super.retrieveAttribute(attribute);
}
}
}
class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
FullTimeEmployee fullTimeEmployee = new FullTimeEmployee(101, "Alice", 50000, 5000);
PartTimeEmployee partTimeEmployee = new PartTimeEmployee(102, "Bob", 100, 40);
while (true) {
String command = scanner.nextLine().trim().toLowerCase();
if (command.equals("exit")) {
break;
}
switch (command) {
case "full time employee salary":
System.out.println(fullTimeEmployee.getSalary());
break;
case "update car":
System.out.print("Enter car model to update: ");
String carToUpdate = scanner.nextLine();
if (carInventory.containsKey(carToUpdate)) {
System.out.print("Enter new number of doors: ");
int newDoors = scanner.nextInt();
scanner.nextLine(); // Consume newline
carInventory.get(carToUpdate).update(newDoors);
} else {
System.out.println("Car not found.");
}
break;
case "update bike":
System.out.print("Enter bike model to update: ");
String bikeToUpdate = scanner.nextLine();
if (bikeInventory.containsKey(bikeToUpdate)) {
System.out.print("Does it have a carrier? (true/false): ");
boolean newCarrier = scanner.nextBoolean();
scanner.nextLine(); // Consume newline
bikeInventory.get(bikeToUpdate).update(newCarrier);
} else {
System.out.println("Bike not found.");
}
break;
case "check car":
System.out.print("Enter car model to check: ");
String carToCheck = scanner.nextLine();
System.out.println(carInventory.containsKey(carToCheck) ? "Car exists in inventory." : "Car not found.");
break;
case "check bike":
System.out.print("Enter bike model to check: ");
String bikeToCheck = scanner.nextLine();
System.out.println(bikeInventory.containsKey(bikeToCheck) ? "Bike exists in inventory." : "Bike not found.");
break;
case "exit":
System.out.println("Exiting system...");
scanner.close();
return;
default:
System.out.println("Invalid command.");
}
}
}
}
#veihcle_management_system_using_java
#L&T
import java.util.*;
class Vehicle {
protected String make;
protected String model;
protected int year;
public Vehicle(String make, String model, int year) {
this.make = make;
this.model = model;
this.year = year;
}
public void display() {
System.out.print(make + ", " + model + ", " + year);
}
}
class Car extends Vehicle {
private int numDoors;
public Car(String make, String model, int year, int numDoors) {
super(make, model, year);
this.numDoors = numDoors;
}
@Override
public void display() {
super.display();
System.out.println(", " + numDoors + " doors");
}
public void update(int numDoors) {
this.numDoors = numDoors;
System.out.println("Car updated successfully.");
}
}
class Bike extends Vehicle {
private boolean hasCarrier;
public Bike(String make, String model, int year, boolean hasCarrier) {
super(make, model, year);
this.hasCarrier = hasCarrier;
}
@Override
public void display() {
super.display();
System.out.println(", " + (hasCarrier ? "Has Carrier" : "No Carrier"));
}
public void update(boolean hasCarrier) {
this.hasCarrier = hasCarrier;
System.out.println("Bike updated successfully.");
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Map<String, Car> carInventory = new HashMap<>();
Map<String, Bike> bikeInventory = new HashMap<>();
while (true) {
String command = scanner.nextLine().toLowerCase();
switch (command) {
case "add car":
System.out.print("Enter make: ");
String carMake = scanner.nextLine();
System.out.print("Enter model: ");
String carModel = scanner.nextLine();
System.out.print("Enter year: ");
int carYear = scanner.nextInt();
System.out.print("Enter number of doors: ");
int numDoors = scanner.nextInt();
scanner.nextLine(); // Consume newline
carInventory.put(carModel, new Car(carMake, carModel, carYear, numDoors));
System.out.println("Car added successfully.");
break;
case "add bike":
System.out.print("Enter make: ");
String bikeMake = scanner.nextLine();
System.out.print("Enter model: ");
String bikeModel = scanner.nextLine();
System.out.print("Enter year: ");
int bikeYear = scanner.nextInt();
System.out.print("Does it have a carrier? (true/false): ");
boolean hasCarrier = scanner.nextBoolean();
scanner.nextLine(); // Consume newline
bikeInventory.put(bikeModel, new Bike(bikeMake, bikeModel, bikeYear, hasCarrier));
System.out.println("Bike added successfully.");
break;
case "display car":
System.out.print("Enter car model: ");
String carToDisplay = scanner.nextLine();
if (carInventory.containsKey(carToDisplay)) {
carInventory.get(carToDisplay).display();
} else {
System.out.println("Car not found.");
}
break;
case "display bike":
System.out.print("Enter bike model: ");
String bikeToDisplay = scanner.nextLine();
if (bikeInventory.containsKey(bikeToDisplay)) {
bikeInventory.get(bikeToDisplay).display();
} else {
System.out.println("Bike not found.");
}
break;
import java.util.PriorityQueue;
import java.util.Scanner;
class ListNode {
int val;
ListNode next;
ListNode(int val) {
this.val = val;
this.next = null;
}
}
public class Main {
public static ListNode mergeKLists(ListNode[] lists) {
PriorityQueue<ListNode> minHeap = new PriorityQueue<>((a, b) -> a.val - b.val);
for (ListNode list : lists) {
if (list != null) {
minHeap.add(list);
}
}
ListNode dummy = new ListNode(-1);
ListNode current = dummy;
while (!minHeap.isEmpty()) {
ListNode smallest = minHeap.poll();
current.next = smallest;
current = current.next;
if (smallest.next != null) {
minHeap.add(smallest.next);
}
}
return dummy.next;
}
public static ListNode arrayToLinkedList(int[] arr) {
if (arr.length == 0) return null;
ListNode head = new ListNode(arr[0]);
ListNode current = head;
for (int i = 1; i < arr.length; i++) {
current.next = new ListNode(arr[i]);
current = current.next;
}
return head;
}
public static void printLinkedList(ListNode head) {
ListNode current = head;
while (current != null) {
System.out.print(current.val + " ");
current = current.next;
}
System.out.println();
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int k = scanner.nextInt(); // Number of linked lists
ListNode[] lists = new ListNode[k];
scanner.nextLine(); // Move to next line
for (int i = 0; i < k; i++) {
String[] elements = scanner.nextLine().split(" ");
int[] arr = new int[elements.length];
for (int j = 0; j < elements.length; j++) {
arr[j] = Integer.parseInt(elements[j]);
}
lists[i] = arrayToLinkedList(arr);
}
ListNode mergedHead = mergeKLists(lists);
printLinkedList(mergedHead);
scanner.close();
}
}
#MERGE_K_SORTED_ARRAYS
#L&T
اکنون در دسترس! پژوهش تلگرام ۲۰۲۵ — مهمترین بینشهای سال 
