Groovy Programming Fresco Play Handson Answers
Groovy Programming Fresco Play Handson Answers
//Enter your code here. Read input from STDIN. Print output to STDOUT
class Solution{
class Solution {
}
3. String datatype - Hands On
class Solution {
println stringLength
class Solution {
println square
println cube
}
5. Lists - Hands On
class Solution {
println primes
6. Maps - Hands On
class Solution {
def students = [
name : 'Rohit',
age : 23,
city : 'London',
marks : [
science : 95,
english : 88
]
]
println students.size()
println students.name
println students.age
println students
7. Ranges - Hands On
class Solution {
import java.text.SimpleDateFormat
import java.util.Scanner
class Solution {
import java.util.Scanner
class Solution {
println addition
println subtraction
println multiplication
println division
println remainder
import java.util.Scanner
class Solution {
println equal
println notEqual
println greaterThan
println lessThan
println greaterOrEqual
println lessOrEqual
import java.util.Scanner
class Solution {
// Read the two boolean values as strings and convert them to booleans
def a = scanner.nextBoolean()
def b = scanner.nextBoolean()
def orResult = a || b
def notA = !a
def notB = !b
println andResult
println orResult
println notA
println notB
}
12. Bitwise Operators - Hands On
import java.util.Scanner
class Solution {
println bitwiseAnd
println bitwiseOr
println bitwiseXor
println onesComplementNum1
println onesComplementNum2
import java.util.Scanner
class Solution {
// Read input
int x = scanner.nextInt()
int y = scanner.nextInt()
x += y
println x // 13
x -= y
println x // 10
x *= y
println x // 30
println x // 10
println x // 1
class Solution {
car.name = "Honda"
car.year = 2009
// Print values
println car.name
println car.year
println car.model
class Car {
String name
int year
String model
class Solution {
def x = 10
def y = "Test"
def z = 101.90
println x.getClass()
println y.getClass()
println z.getClass()
println list.getClass()
class Student {
int ID
String firstName
String lastName
String school
class Solution {
student.ID = 101
student.firstName = "John"
student.lastName = "Doe"
println student.ID
println student.firstName
println student.lastName
println student.school
class TypeChecker {
println n.getClass()
println str.getClass()
class Solution {
if (sqrt == sqrt.toInteger()) {
println true
} else {
println false
class Solution {
} else {
} else {
class Solution {
if (proficiency == "E0") {
proficiency = "EO"
switch (proficiency) {
case "EO":
break
case "E1":
break
case "E2":
break
default:
class Solution {
def n = System.in.newReader().readLine().toInteger()
// Initialize variables
def sum = 0
def i = 1
sum += i
i++
println sum
class Solution {
def n = System.in.newReader().readLine().toInteger()
def sumOfDivisors = 0
if (n % i == 0) { // Check if i is a divisor of n
sumOfDivisors += i
if (sumOfDivisors == n) {
println "true"
} else {
println "false"
}
class Solution {
// Use a for-in loop to iterate over the list and print each element
println fruit
class Solution {
// - It is divisible by 400
return true
return false
}
static void main(String[] args) {
if (checkLeap(year)) {
println "true"
} else {
println "false"
class Solution {
try {
if (!map.containsKey('Address')) {
println map['Address']
} catch (Exception e) {
// Catch the error and print the custom message