ppl&dbtSlip8
Q1: -
CREATE (john:Person {name: 'John', city: 'Pune', project: 'Finance'}),
(emma:Person {name: 'Emma', city: 'Mumbai', project: 'Sales'}),
(raj:Person {name: 'Raj', city: 'Pune', project: 'Inventory'}),
(priya:Person {name: 'Priya', city: 'Kolhapur', project: 'Finance'}),
(vikas:Person {name: 'Vikas', city: 'Mumbai', project: 'Finance'}),
(neha:Person {name: 'Neha', city: 'Pune', project: 'Sales'})
MATCH (john:Person {name: 'John'}), (emma:Person {name: 'Emma'})
WITH john, emma
CREATE (john)-[:FRIEND]->(emma), (emma)-[:FRIEND]->(john)
WITH john, emma
MATCH (raj:Person {name: 'Raj'}), (priya:Person {name: 'Priya'})
WITH raj, priya
CREATE (raj)-[:FRIEND]->(priya), (priya)-[:FRIEND]->(raj)
WITH raj, priya
MATCH (john:Person {name: 'John'}), (vikas:Person {name: 'Vikas'})
WITH john, vikas
CREATE (john)-[:FRIEND]->(vikas), (vikas)-[:FRIEND]->(john)
WITH john, vikas
MATCH (neha:Person {name: 'Neha'}), (emma:Person {name: 'Emma'})
WITH neha, emma
CREATE (neha)-[:FRIEND]->(emma), (emma)-[:FRIEND]->(neha)
MATCH (p:Person {city: 'Pune'})
RETURN p.name AS PersonsInPune
MATCH (p:Person {project: 'Finance'})
RETURN p.name AS PersonsInFinanceProject
Q2:-
import scala.io.StdIn._
class Employee(val id: Int, val name: String, val salary: Double) {
// Method to display employee details
def display(): Unit = {
println(s"Employee ID: name")
println(f"Employee Salary: $$${salary}%.2f")
}
}
object EmployeeApp {
def main(args: Array[String]): Unit = {
// Create a list to hold employees
val employees = scala.collection.mutable.ListBufferEmployee
// Accept details for a specific number of employees
println("Enter the number of employees:")
val n = readInt()
for (_ <- 1 to n) {
println("Enter Employee ID:")
val id = readInt()
println("Enter Employee Name:")
val name = readLine()
println("Enter Employee Salary:")
val salary = readDouble()
// Create a new Employee object and add it to the list
val employee = new Employee(id, name, salary)
employees += employee
}
// Find the employee with the maximum salary
val maxSalaryEmployee = employees.maxBy(_.salary)
// Display details of the employee with maximum salary
println("\nDetails of the employee with maximum salary:")
maxSalaryEmployee.display()
}
}