Problem 2:
using System;
using [Link];
using [Link];
class Employee {
public int EmployeeID { get; set; }
public string Name { get; set; }
public string Department { get; set; }
public decimal Salary { get; set; }
class Program {
static void Main() {
// Sample list of employees
List<Employee> employees = new List<Employee> {
new Employee { EmployeeID = 1, Name = "Alice", Department = "IT", Salary = 60000 },
new Employee { EmployeeID = 2, Name = "Bob", Department = "HR", Salary = 55000 },
new Employee { EmployeeID = 3, Name = "Charlie", Department = "IT", Salary = 105000 },
new Employee { EmployeeID = 4, Name = "David", Department = "IT", Salary = 75000 },
new Employee { EmployeeID = 5, Name = "Eva", Department = "Finance", Salary = 50000
}
};
// LINQ Query: Filter IT department employees with salary between 50k and 100k
var filteredEmployees = employees
.Where(e => [Link] == "IT" && [Link] >= 50000 && [Link] <= 100000);
[Link]("Filtered IT Employees (Salary between 50k - 100k):");
foreach (var emp in filteredEmployees) {
[Link]($"ID: {[Link]}, Name: {[Link]}, Salary: {[Link]}");
Problem 3:
using System;
enum RocketStage {
PreLaunch,
Liftoff,
StageSeparation,
OrbitInsertion,
Reentry,
Landing,
Complete
}
class Rocket {
private RocketStage currentStage;
public Rocket() {
currentStage = [Link];
}
public void AdvanceStage() {
switch (currentStage) {
case [Link]:
[Link]("Preparing for launch.");
break;
case [Link]:
[Link]("Liftoff! Rocket is ascending.");
break;
case [Link]:
[Link]("Stage separation successful.");
break;
case [Link]:
[Link]("Rocket has reached orbit.");
break;
case [Link]:
[Link]("Reentering Earth's atmosphere.");
break;
case [Link]:
[Link]("Rocket has landed successfully.");
break;
}
// Advance to next stage
currentStage = (RocketStage)((int)currentStage + 1);
}
public bool IsComplete() {
return currentStage == [Link];
}
}
class Program {
static void Main() {
Rocket spacexRocket = new Rocket();
while (![Link]()) {
[Link]();
}
}
}
Problem 4:
using System;
enum ImplantMode {
Idle,
DataProcessing,
NeuroStimulation,
SleepMode
}
class NeuralinkDevice {
private ImplantMode currentMode;
public NeuralinkDevice() {
currentMode = [Link];
}
public void SwitchMode(ImplantMode mode) {
currentMode = mode;
[Link]($"Device switched to: {currentMode}");
PerformModeAction();
}
private void PerformModeAction() {
switch (currentMode) {
case [Link]:
[Link]("System is idle, waiting for signals.");
break;
case [Link]:
[Link]("Processing neural data...");
break;
case [Link]:
[Link]("Sending stimulation pulses to brain
regions.");
break;
case [Link]:
[Link]("Device is now in low-power sleep mode.");
break;
}
}
}
class Program {
static void Main() {
NeuralinkDevice device = new NeuralinkDevice();
while (true) {
[Link]("\nChoose a mode:");
[Link]("0 - Idle");
[Link]("1 - DataProcessing");
[Link]("2 - NeuroStimulation");
[Link]("3 - SleepMode");
[Link]("Any other key - Exit");
string input = [Link]();
if ([Link](input, out int modeNumber) &&
modeNumber >= 0 && modeNumber <= 3) {
[Link]((ImplantMode)modeNumber);
} else {
[Link]("Exiting simulation.");
break;
}
}
}
}
Program 5:
using System;
enum AutonomyLevel {
Manual,
AssistedDriving,
Autonomous,
EmergencyOverride
}
class TeslaCar {
private AutonomyLevel currentLevel;
public void SetAutonomy(AutonomyLevel level) {
currentLevel = level;
[Link]($"Autonomy level set to: {currentLevel}");
DescribeLevel();
}
private void DescribeLevel() {
switch (currentLevel) {
case [Link]:
[Link]("Driver is in full control.");
break;
case [Link]:
[Link]("Assisting with lane-keeping and adaptive
cruise control.");
break;
case [Link]:
[Link]("Fully autonomous driving mode
activated.");
break;
case [Link]:
[Link]("Emergency override engaged. Returning
control to driver.");
break;
}
}
}
class Program {
static void Main() {
TeslaCar car = new TeslaCar();
while (true) {
[Link]("\nEnter road condition (rain / highway /
urban / emergency / exit):");
string condition = [Link]().ToLower();
switch (condition) {
case "rain":
[Link]([Link]);
break;
case "highway":
[Link]([Link]);
break;
case "urban":
[Link]([Link]);
break;
case "emergency":
[Link]([Link]);
break;
case "exit":
[Link]("Ending simulation.");
return;
default:
[Link]("Unknown condition. Try again.");
break;
}
}
}
}