OneCompiler

ppl&dbtSlip10

1661

Q1:-

CREATE (math:Department {name: 'Mathematics', location: 'Building A'}),
(geo:Department {name: 'Geology', location: 'Building B'}),
(chem:Department {name: 'Chemistry', location: 'Building C'}),
(cs:Department {name: 'Computer Science', location: 'Building D'})

CREATE (calculus:Course {name: 'Calculus', code: 'MATH101', credits: 4}),
(geology101:Course {name: 'Introduction to Geology', code: 'GEO101', credits: 3}),
(organicChemistry:Course {name: 'Organic Chemistry', code: 'CHEM201', credits: 4}),
(dataStructures:Course {name: 'Data Structures', code: 'CS102', credits: 3}),
(databases:Course {name: 'Database Systems', code: 'CS201', credits: 3}),
(chemistry101:Course {name: 'General Chemistry', code: 'CHEM101', credits: 4}),
(chemistryData:Course {name: 'Chemistry Data Science', code: 'CHEM202', credits: 3})

CREATE (chem)-[:CONDUCTS]->(organicChemistry),
(chem)-[:CONDUCTS]->(chemistry101),
(math)-[:CONDUCTS]->(calculus),
(geo)-[:CONDUCTS]->(geology101),
(cs)-[:CONDUCTS]->(dataStructures),
(cs)-[:CONDUCTS]->(databases),
(chem)-[:CONDUCTS]->(chemistryData),
(cs)-[:CONDUCTS]->(chemistryData)

MATCH (chem:Department {name: 'Chemistry'})-[:CONDUCTS]->(c:Course)
RETURN c.name AS Course, c.code AS Code, c.credits AS Credits

MATCH (chem:Department {name: 'Chemistry'})-[:CONDUCTS]->(c:Course)<-[:CONDUCTS]-(cs:Department {name: 'Computer Science'})
RETURN c.name AS Course, c.code AS Code, c.credits AS Credits

Q2:-

object FunctionListGenerator {

// Function to calculate the value based on the formula 3n^2 + 4n + 6
def calculate(n: Int): Int = {
3 * n * n + 4 * n + 6
}

def main(args: Array[String]): Unit = {
// Create a list of 10 members using the calculate function
val members: List[Int] = (1 to 10).map(calculate).toList

// Print the generated list
println("List of 10 members using the function 3n^2 + 4n + 6:")
println(members)

}
}