ppl&dbtSlip6
Q1:-
CREATE (p1:Publisher {name: 'Publisher A', location: 'Mumbai', established_year: 1990}),
(p2:Publisher {name: 'Publisher B', location: 'Delhi', established_year: 1985}),
(p3:Publisher {name: 'Publisher C', location: 'Mumbai', established_year: 2000}),
(p4:Publisher {name: 'Publisher D', location: 'Chennai', established_year: 1995}),
(p5:Publisher {name: 'Publisher E', location: 'Mumbai', established_year: 2010}),
(p6:Publisher {name: 'Publisher F', location: 'Kolkata', established_year: 1998}),
(p7:Publisher {name: 'Publisher G', location: 'Mumbai', established_year: 2005}),
(p8:Publisher {name: 'Publisher H', location: 'Delhi', established_year: 2018}),
(p9:Publisher {name: 'Publisher I', location: 'Pune', established_year: 2016}),
(p10:Publisher {name: 'Publisher J', location: 'Mumbai', established_year: 2020});
CREATE (b1:Book {title: 'Book A', author: 'Author A', cost: 1200}),
(b2:Book {title: 'Book B', author: 'Author B', cost: 800}),
(b3:Book {title: 'Book C', author: 'Author C', cost: 1500}),
(b4:Book {title: 'Book D', author: 'Author D', cost: 950}),
(b5:Book {title: 'Book E', author: 'Author E', cost: 600}),
(b6:Book {title: 'Book F', author: 'Author F', cost: 2000}),
(b7:Book {title: 'Book G', author: 'Author G', cost: 750}),
(b8:Book {title: 'Book H', author: 'Author H', cost: 1100}),
(b9:Book {title: 'Book I', author: 'Author I', cost: 990}),
(b10:Book {title: 'Book J', author: 'Author J', cost: 1350});
CREATE (p1)-[:PUBLISHES]->(b1),
(p1)-[:PUBLISHES]->(b2),
(p3)-[:PUBLISHES]->(b3),
(p4)-[:PUBLISHES]->(b4),
(p5)-[:PUBLISHES]->(b5),
(p6)-[:PUBLISHES]->(b6),
(p7)-[:PUBLISHES]->(b7),
(p8)-[:PUBLISHES]->(b8),
(p9)-[:PUBLISHES]->(b9),
(p10)-[:PUBLISHES]->(b10);
MATCH (p:Publisher)
WHERE p.location = 'Mumbai'
RETURN p.name AS Publisher_Name, p.established_year AS Established_Year;
MATCH (b:Book)
WHERE b.cost > 1000
RETURN b.title AS Book_Title, b.author AS Author, b.cost AS Cost;
Q2:-
import scala.io.StdIn._
object StringOperations {
def main(args: Array[String]): Unit = {
// Read two strings from the user
println("Enter the first string:")
val firstString = readLine()
println("Enter the second string:")
val secondString = readLine()
// a. Concatenate two strings
val concatenatedString = firstString + secondString
println(s"Concatenated String: $concatenatedString")
// b. Check if first string ends with "la"
val endsWithLa = firstString.endsWith("la")
if (endsWithLa) {
println(s"The first string '$firstString' ends with 'la'.")
} else {
println(s"The first string '$firstString' does not end with 'la'.")
}
// c. Find the index of character 'a' in the second string
val indexOfA = secondString.indexOf('a')
if (indexOfA != -1) {
println(s"The character 'a' is found at index: $indexOfA in the second string '$secondString'.")
} else {
println(s"The character 'a' is not found in the second string '$secondString'.")
}
}
}