-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootcamp.dart
91 lines (80 loc) · 1.72 KB
/
Bootcamp.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
void main() {
print("This is my first sentence");
}
void secondary() {
var x = 5;
print(x);
}
void third() {
print("Ross" + " " + "Cooper");
}
void four() {
num x = 100;
x--;
print(x);
//result 99
}
void operatetions() {
num x = 7;
x ~/= 2;
print(x);
}
void fifth() {
// Conversion of units
// inputs
num f = 273;
num c = 273;
num k = 273;
//conversion
final convertC = (f - 32) / 1.8;
final convertF = 1.8 * c + 32;
final convertK = c + 273.15;
print("$f degrees Fahrenheit is $convertC degrees Celsius.");
print("$c degrees Celsius is $convertF degrees Fahrenheit.");
print("$k degrees Kelvin is $convertK degrees Celcius");
}
void tempcond() {
num cold = 15;
num temp = 24;
print("Is it cold out?");
if (temp > cold) {
print("No, it's warm");
} else if (temp == cold) {
print("Maybe best to grab a sweater");
} else {
print("It's cold out, take a jacket");
}
}
//This is an example where the bootcamp says it's better to use if/else rather than switch
void switch_or_if() {
num score = 79.9;
String grade = " ";
if (score >= 90) {
grade = "A";
} else if (score >= 80) {
grade = "B";
} else if (score >= 70) {
grade = "C";
} else if (score >= 60) {
grade = "D";
} else {
grade = "F";
}
print("Score: $score");
print("Grade: $grade");
}
void loop() {
for (int milk = 99; milk > 0; milk--) {
print("$milk bottles of milk on the wall, $milk bottles of milk.");
print("You take one down, pass it around... ");
print("${milk - 1} bottles of milk on the wall.\n");
}
}
void greet(String recipient) {
print("Hello $recipient!");
}
void resultSum() {
int answer = sum(1000, 2900);
print(answer);
}
int sum(int a, int b) => a + b;