Loading workspace environment...
Get started with Groovy syntax, structure, and writing your first program.
// Apache Groovy 4 Syntax & Learning Sandbox
def calculateTax(price, rate = 0.08) {
return price * (1 + rate)
}
def items = [
[name: 'Laptop', price: 1200],
[name: 'Monitor', price: 350],
[name: 'Keyboard', price: 95]
]
items.each { item ->
def total = calculateTax(item.price)
println "Item: ${item.name} | Total w/ Tax: $${total.round(2)}"
}