Note If you don’t know how to solve an problem, or what is the function to be used, you could search on Internet for the answer using the API of the Java programming language. Indeed, since SARL is fully compatible with the Java API, you could use all the types or functions that are defined in this Java API.
Write a SARL program to print the following string in a specific format (see the output).
Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are
Twinkle, twinkle, little star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are
Write a SARL program to display the current date and time.
Current date and time:
2014-07-05 14:34:14
Write a SARL program that calculates the area of a circle based on the radius entered by the user from the command line when your are launching the agent.
r = 1.1
Area = 3.8013271108436504
Write a SARL program that accepts the user’s first and last name as inputs from the command line, and prints them in reverse order with a space between them.
Write a SARL program that accepts a sequence of comma-separated numbers from the command line and generates a list of those numbers.
3, 5, 7, 23
List : ['3', ' 5', ' 7', ' 23']
Write a SARL program that accepts a filename from the command line, and prints the extension of the file.
abc.sarl
sarl
Write a SARL program to display the first and last colors from the following list.
color_list = ["Red","Green","White" ,"Black"]
Write a SARL program that accepts an integer (n) on the command line and computes the value of n+nn+nn*n.
Write a SARL program that prints the calendar for a given month and year.
Write a SARL program to calculate the number of days between two dates.
(2014, 7, 2)
, (2014, 7, 11)
Write a SARL program to get the volume of a sphere with radius six.
Write a SARL program to calculate the difference between a given number and 17. If the number is greater than 17, return twice the absolute difference.
Write a SARL program to test whether a number is within 100 of 1000 or 2000.
Write a SARL program to calculate the sum of three given numbers, that are provided on the command line. If the values are equal, return three times their sum.
Write a SARL program to get a newly-generated string from a given string where Is
has been added to the front. Return the string unchanged if the given string already begins with Is
.
Write a SARL program that returns a string that is n (non-negative integer) copies of a given string (from the command line).
Write a SARL program that determines whether a given number (accepted from the command line) is even or odd, and prints an appropriate message to the user.
Write a SARL program to count the number 4 in a given list, provided on the command line.
Write a SARL program to get n (non-negative integer) copies of the first 2 characters of a given string (from the command line). Return n copies of the whole string if the length is less than 2.
Write a SARL program to test whether a passed letter from the command line is a vowel or not.
Write a SARL program that checks whether a specified value is contained within a group of values.
3 -> [1, 5, 8, 3] : True
-1 -> [1, 5, 8, 3] : False
Write a SARL program that concatenates all elements in a list into a string and returns it.
Write a SARL program to print all even numbers from a given list of numbers in the same order and stop printing any after 237 in the sequence.
numbers = [
386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345,
399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217,
815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717,
958,743, 527
]
Write a SARL program that prints out all colors from color_list_1
that are not present in color_list_2
.
color_list_1 = set(["White", "Black", "Red"])
color_list_2 = set(["Red", "Green"])
{'Black', 'White'}
Write a SARL program that will accept the base and height of a triangle and compute its area.
Write a SARL program that computes the greatest common divisor (GCD) of two positive integers.
Write a SARL program to find the least common multiple (LCM) of two positive integers.
Write a SARL program to sum three given integers. However, if two values are equal, the sum will be zero.
Write a SARL program to sum two given integers. However, if the sum is between 15 and 20 it will return 20.
Write a SARL program that returns true
if the two given integer values are equal or their sum or difference is 5.
Write a SARL program to add two objects if both objects are integers.
Write a SARL program to solve (x + y) * (x + y)
.
x = 4, y = 3
(4 + 3) ^ 2 = 49
Write a SARL program to calculate the distance between the points (x1, y1) and (x2, y2).
Write a SARL program to check whether a file exists, when the name of the file is provided from the command line. Use the Java API.
Write a SARL program to parse a string to float or integer.
Write a SARL program to list all files in a directory.
Write a SARL program to print a message provided from the command line without a newline or space.
Write a SARL program to print to STDERR (standard error output of the process).
Write a SARL program to access environment variables.
Write a SARL program to get the current username.
Write a SARL program to sum the first n positive integers.
Write a SARL program to convert height (in feet and inches) to centimeters, when the value is provided from the command line.
Write a SARL program to calculate the hypotenuse of a right angled triangle.
Write a SARL program to convert all units of time into seconds.
Write a SARL program to get an absolute file path from a name that is provided on the command line.
Write a SARL program that converts seconds into days, hours, minutes, and seconds.
Write a SARL program to calculate the body mass index.
Write a SARL program to convert pressure in kilopascals to pounds per square inch, a millimeter of mercury (mmHg) and atmosphere pressure.
Write a SARL program to calculate sum of digits, from a string of characters, of a number.
Write a SARL program to sort three integers without using conditional statements and loops.
Write a SARL program to concatenate N strings.
Write a SARL program to calculate the sum of all items of a container (array, list, set).
Write a SARL program to test whether all numbers in a list, provided on the command line, are greater than a certain number, provided also on command line.
Write a SARL program to count the number of occurrences of a specific character in a string.
Write a SARL program to check whether a file path, provided on the command line, is a file or a directory.
Write a SARL program to swap two variables.
Write a SARL program to check whether a string is numeric.
Write a SARL program to prove that two string variables of the same value point to the same memory location.
Write a SARL program to determine the largest and smallest integers, longs, and floats.
Copyright © 2014-2024 SARL.io, the Original Authors and Main Authors.
Documentation text and medias are licensed under the Creative Common CC-BY-SA-4.0; you may not use this file except in compliance with CC-BY-SA-4.0. You may obtain a copy of CC-BY-4.0.
Examples of SARL code are licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the Apache License. You may obtain a copy of the Apache License.
You are free to reproduce the content of this page on copyleft websites such as Wikipedia.
Generated with the translator docs.generator 0.14.0.