-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSession1HW.dart
More file actions
57 lines (44 loc) · 1000 Bytes
/
Session1HW.dart
File metadata and controls
57 lines (44 loc) · 1000 Bytes
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
// // Program for Water Bottle Sensor:
// It has 3 operations-->
// 1. Update how much water we drank.
// 2. Update if it is empty.
// 3. Update if it is refilled.
// need to maintain the quantity in all 3 secenarios.
void main() {
//water measure in litres
double threshold_value=7.5;
double sensor=7.5;
double water_drank= 6.5;
double water_fill=7.5;
//first scenario
// full
if (sensor==threshold_value)
{
print("Water bottle is full");
}
//empty
if(sensor==0.0)
{
print("water bottle is empty.");
}
//2nd scenario
if (water_drank<=sensor)
{
sensor-=water_drank;
print("${sensor} litre of water is left.");
}
else
{
print("required water is not in the bottle");
}
//3rd scenario
if (water_fill>(threshold_value-sensor))
{
print("Water is more that the water bottle can contain");
}
else
{
sensor+=water_fill;
print("${sensor} litre of water is in the bottle");
}
}