Use the following quick reference to solve the exercises in this practical sheet. All the programs should be in Dart.
// import some I/O functions
import 'dart:io';
// import some math functions
import 'dart:math';
// Read a string from standard input
String word = stdin.readLineSync()!;
// Index a string
String letter = word[0];
// Create and initiliase a list
List<int> list = [1, 2, 3];
// Create and initialise a set
Set<int> set = {};
// write to standard output
stdout.write("... $str ...");
print("... $str ...");
// loop through the elements of a list
for(int i = 1; i < list.length; i++)
{
...
}
// also loop
for(int item in list)
{
...
}
// create a random integer
int random = Random().nextInt(100);
Question 01
Write a program that prompts the user to enter their name and age. The program should output how many years are left until the user reaches 100 years of age.
Question 02
Create a program that asks the user for a number. Based on whether the number is even or odd, print an appropriate message.
Question 03
Given an integer list, write a program that prints all elements in the list that are less than 5.
Question 04
Develop a program that asks the user for a number and outputs a list of all its divisors.
Question 05
Given two integer lists, write a program that returns a list containing only the elements that are common between them (without duplicates).
Question 06
Create a program that asks the user for a string and checks if it is a palindrome.
Question 07
Given an integer list, write a program that generates a new list containing only the even elements from the original list.