Skip to content

Instantly share code, notes, and snippets.

@ibrohimkhan
Created March 12, 2021 21:07
Show Gist options
  • Save ibrohimkhan/1ca1fee7313e595dd73c87f849926eb4 to your computer and use it in GitHub Desktop.
Save ibrohimkhan/1ca1fee7313e595dd73c87f849926eb4 to your computer and use it in GitHub Desktop.

Revisions

  1. ibrohimkhan created this gist Mar 12, 2021.
    73 changes: 73 additions & 0 deletions assignment_2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    import 'dart:io';

    void main(List<String> arguments) {
    task1();
    }

    void task1() {
    var month = 8;

    switch (month) {
    case 1:
    print('January');
    break;
    case 2:
    print('February');
    break;
    case 3:
    print('March');
    break;
    case 4:
    print('April');
    break;
    case 5:
    print('May');
    break;
    case 6:
    print('June');
    break;
    case 7:
    print('July');
    break;
    case 8:
    print('August');
    break;
    case 9:
    print('September');
    break;
    case 10:
    print('October');
    break;
    case 11:
    print('November');
    break;
    case 12:
    print('December');
    break;
    default:
    print('There is no such month');
    }
    }

    void task2() {
    // step 2 is used to avoid looping 100 times
    for (var i = 0; i < 100; i += 2) {
    print('i = $i');
    }
    }

    void task3() {
    var sum = 0;

    while (true) {
    var data = stdin.readLineSync();
    if (data == 'stop') break;

    var number = num.tryParse(data);
    if (number == null) continue;

    sum += number;
    }

    print('sum is $sum');
    }