Line: 1 to 1 | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Course on Internet of Things Exercises Session 1: | |||||||||||||||||||
Line: 38 to 38 | |||||||||||||||||||
Bonus points: Writing a parser for user input is rather easy if the numbers and operator are separated by spaces (have a look at the split method of strings). It is quite a bit more tricky if you allow entering calculations without spaces between the operands and the operator. Can you write a parser accomplishing this? Try your parser on this input: | |||||||||||||||||||
Added: | |||||||||||||||||||
> > |
| ||||||||||||||||||
Deleted: | |||||||||||||||||||
< < | 5.3+4.7 ok 5.3++4.7 not ok 5..3 + 4.7 not ok .3+.7 ok 5.3+4b7 not ok | ||||||||||||||||||
Exercise 3: | |||||||||||||||||||
Changed: | |||||||||||||||||||
< < | Like in exercise2, start with 2 number a,b with values 5 and 3. In your program check which of the 2 numbers is bigger and print the result. Then ask the user for 2 integer numbers. Make sure he enters 2 correct numbers and capture possible errors. This is a typical output: | ||||||||||||||||||
> > | Like in exercise2, start with 2 numbers a,b with values 5 and 3. In your program check which of the 2 numbers is bigger and print the result. Then improve the program asking the user for 2 integer numbers. Make sure he enters 2 correct numbers and capture possible errors. This is a typical output: | ||||||||||||||||||