Skip to content

Latest commit

 

History

History
90 lines (64 loc) · 2.47 KB

dart_1_tasks.md

File metadata and controls

90 lines (64 loc) · 2.47 KB

Hello we have multible stages of tasks here

Easy Tasks

1- make a Map with String keys and dynamic values in each one the key will be the Data type Name that we take in course and the value will be the example of this data type.

ex:- {"double" : 3.147}

2- make a list of Maps which have student name as key and grade as value

3- compare by 1 and '1' in if else statement

4- do the example of dynamic and object data types that tells the difference between them

5- print from 1 to 100 by for loop once and while loop in another, note: 100 is included


Medium Task

1- add a Subtract functional button so called horizontal_rule in this Flutter code task(1).txt

to get the result like that :

WhatsApp.Video.2022-02-09.at.7.25.43.PM.mp4

Hard Task

1- Make three functions 1-inputHandler 2-SummationOfNums 3-mapOfSummations at least, of course you can make more.

the target is that SummationOfNums will get integer ex:5 and sum all numbers from 1 to 5, the answer should be 15

inputHandler will take endless list of input like that

image

here "anything .." sentence is my input and 'end of list' is just printed string to interact with user

Note: only the user who can dedict the size of the list

lastly the mapOfSummation will make the input integer as the String key of map and the value is the result of summation


Done.

My take for Hard Task

import 'dart:io';

void main() {
  print(mapOfSummition());
}

List<int> inputHandler() {
    bool notDone = true;
    List<int> ranges = [];
    while (notDone) {
      String? input = stdin.readLineSync();
      try {
        int range = int.parse(input!);
        ranges.add(range);
      } catch (e) {
        notDone = false;
        print("end of list");
      }
    }
    return ranges;
  }

  int summationOfNums(int range) {
    int commulative = 0;
    for (int i = 0; i <= range; i++) {
      commulative += i;
    }
    return commulative;
  }

  Map<String, int> mapOfSummition() {
    Map<String, int> results = {};
    List<int> ranges = inputHandler();
    int l = ranges.length;
    for (int i = 0; i < l; i++) {
      results["Sum of ${ranges[i]}"] = summationOfNums(ranges[i]);
    }
    return results;
  }