-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.ino
49 lines (46 loc) · 991 Bytes
/
4.ino
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
float r;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("1st Input: " );
while (Serial.available()==0){}
int x = Serial.parseInt();
Serial.println(x);
Serial.print("2nd Input: " );
while (Serial.available()==0){}
int y = Serial.parseInt();
Serial.println(y);
Serial.print("Operation: " );
while (Serial.available()==0){}
String z = Serial.readString();
Serial.println(z);
if(z == "add"){
r = x+y;
Serial.print("Output: ");
Serial.println(r);
Serial.print("\n");
}
else if(z == "sub"){
r = x-y;
Serial.print("Output: ");
Serial.println(r);
Serial.print("\n");
}
else if(z == "mult"){
r = x*y;
Serial.print("Output: ");
Serial.println(r);
Serial.print("\n");
}
else if(z == "div"){
r = x/y;
Serial.print("Output: ");
Serial.println(r);
Serial.print("\n");
}
else{
Serial.print("Invalid Operation");
Serial.print("\n");
}
}