1
00:00:01,150 --> 00:00:05,590
Welcome back in this video, we're going to finalize our application, and therefore I'm just going

2
00:00:05,590 --> 00:00:06,670
to get started by.

3
00:00:07,030 --> 00:00:12,760
Well, copy and paste this code because this is basically where the calculation happens, right?

4
00:00:12,760 --> 00:00:14,670
So we check, is it the minus?

5
00:00:14,680 --> 00:00:20,830
If it's a minus, then we're going to split it at the minus and then we do the calculation here at the

6
00:00:20,830 --> 00:00:21,250
bottom.

7
00:00:21,670 --> 00:00:29,080
So now we just need to replace this or do the same thing with a bunch of ifs for the other operations.

8
00:00:29,290 --> 00:00:34,600
So here let me add else, if then else, and paste it in.

9
00:00:34,960 --> 00:00:38,830
So now I have all four operations here.

10
00:00:39,160 --> 00:00:40,390
So let's start with the minus.

11
00:00:40,390 --> 00:00:42,670
We have that now let's go over to the plus.

12
00:00:43,270 --> 00:00:48,310
So let's add the plus here and add it in the calculation itself as well.

13
00:00:48,670 --> 00:00:58,990
Now let's add the division slash and do the same thing here, and then we just need another one, which

14
00:00:58,990 --> 00:01:00,700
will be the multiplication.

15
00:01:01,090 --> 00:01:08,560
So here we just need to add the multiplication like so and of course, we mustn't forget it here at

16
00:01:08,560 --> 00:01:12,730
the bottom and the actual multiplication as well.

17
00:01:13,570 --> 00:01:17,020
OK, so now let's try this once again.

18
00:01:18,000 --> 00:01:22,950
So 99 Times 99 gives nine thousand eight hundred and one.

19
00:01:23,580 --> 00:01:28,560
Now 66, it was actually let's use sixty six times three.

20
00:01:28,770 --> 00:01:30,420
Well, B 198.

21
00:01:30,930 --> 00:01:31,500
That's good.

22
00:01:31,620 --> 00:01:35,670
Now 99, divided by 66 will be 1.5.

23
00:01:36,540 --> 00:01:38,520
And 66 minus.

24
00:01:39,800 --> 00:01:41,480
Thirty three will be 33.

25
00:01:41,810 --> 00:01:48,620
Plus fifty five is eighty eight, minus sixty eight is twenty and so forth.

26
00:01:48,920 --> 00:01:51,530
So you see that works fine.

27
00:01:52,280 --> 00:01:59,300
Now at this point, you could say I am not super happy with their constantly being a dot zero at the

28
00:01:59,300 --> 00:01:59,540
end.

29
00:01:59,540 --> 00:02:08,870
So if we are working with just whole numbers, I want to get rid of this dot zero and you already know

30
00:02:08,870 --> 00:02:10,759
more or less how this can be done.

31
00:02:11,180 --> 00:02:16,520
You could use a substring, you could use a split here, so both would be fine.

32
00:02:16,760 --> 00:02:23,360
I'm just going to show you my solution to it, and that is going to be a new method that will take care

33
00:02:23,360 --> 00:02:24,020
of just that.

34
00:02:24,470 --> 00:02:33,620
So here I'm going to create this new private function called remove zero after.

35
00:02:34,960 --> 00:02:35,380
Dot.

36
00:02:36,070 --> 00:02:36,490
All right.

37
00:02:36,760 --> 00:02:42,100
And it needs to get the result type string and it will return a string itself.

38
00:02:44,600 --> 00:02:48,770
So the result will be the result of our calculation, and then it will take that and it will return

39
00:02:48,770 --> 00:02:51,380
a string without the dot zero.

40
00:02:51,770 --> 00:02:59,720
So first of all, let's get the value, which will be our result at the beginning.

41
00:02:59,840 --> 00:03:06,980
So when we start, the value will be the result and we only change it if we actually need to change

42
00:03:06,980 --> 00:03:10,700
it, which means if the result contains.

43
00:03:12,380 --> 00:03:18,890
The string of dots zero, which means ninety nine point zero, 33.0 and so forth.

44
00:03:19,670 --> 00:03:28,640
If that's the case, then let me set the value to be the result of the sub string of zero.

45
00:03:29,150 --> 00:03:35,090
Well, start index zero all the way up to result that length minus two.

46
00:03:35,780 --> 00:03:37,310
So what is going on here?

47
00:03:37,610 --> 00:03:41,030
Well, let's just use this here and play the codling.

48
00:03:41,540 --> 00:03:44,750
So we had this Helloworld example earlier.

49
00:03:45,110 --> 00:03:48,950
And here I'm going to use this result.

50
00:03:48,950 --> 00:03:50,390
Length minus two.

51
00:03:50,960 --> 00:03:53,120
OK, so what will this return?

52
00:03:53,990 --> 00:03:54,950
Let's run it.

53
00:03:55,460 --> 00:03:59,120
And of course, my string needs to be used here instead of result.

54
00:03:59,870 --> 00:04:04,370
So here is going to be a returned empty space war.

55
00:04:04,790 --> 00:04:10,790
So what it does is it starts at position zero, which is just empty space, and it goes all the way

56
00:04:10,790 --> 00:04:14,450
to the length of the entire string, which is 11.

57
00:04:14,660 --> 00:04:21,050
So we have 11 entries minus two, so it goes all the way to index nine, which means it goes all the

58
00:04:21,050 --> 00:04:24,600
way to this hour and doesn't use this L.D.

59
00:04:24,830 --> 00:04:30,800
Maybe it's going to be easier if we actually are going to use these as strings here, like the numbers

60
00:04:30,800 --> 00:04:31,280
of strings.

61
00:04:31,640 --> 00:04:37,880
You can see it starts at Index five, which is this number here, and it goes all the way up to everything

62
00:04:37,880 --> 00:04:39,380
except for the last two entries.

63
00:04:39,380 --> 00:04:41,330
So this eight nine is going to be excluded.

64
00:04:41,930 --> 00:04:50,290
It's the same as if it were saying 90.0, and we start at Substring Index zero and go all the way to

65
00:04:50,450 --> 00:04:52,970
length minus two, which means we just get 90.

66
00:04:52,970 --> 00:04:57,440
So we are eliminating the dot zero here with this substring.

67
00:05:00,330 --> 00:05:05,940
And now, of course, we need to return value, so here, return value, like so.

68
00:05:06,510 --> 00:05:10,770
And by the way, what you see here, I'm using this f clause without curly brackets because I just have

69
00:05:10,770 --> 00:05:14,250
one line of code that will be executed for this if statement, if it's true.

70
00:05:14,670 --> 00:05:22,560
So now we return value, which means now we can go ahead and remove zero after dot for each of the calculation

71
00:05:22,560 --> 00:05:24,090
results, so to speak.

72
00:05:24,420 --> 00:05:27,560
OK, so here what we said to the text.

73
00:05:27,570 --> 00:05:34,230
We can now just use this remove after dot and pass the calculation in there.

74
00:05:34,370 --> 00:05:35,670
So the result?

75
00:05:35,850 --> 00:05:40,530
So the string of the result in there as the parameter.

76
00:05:40,530 --> 00:05:44,940
OK, so remove after dot with this thing as a string.

77
00:05:45,090 --> 00:05:49,210
OK, and now we can do the same thing with the other calculations.

78
00:05:49,230 --> 00:05:51,830
So here we do the same thing.

79
00:05:51,840 --> 00:05:55,410
We just need to make sure that we replace it with the right operation.

80
00:05:55,980 --> 00:06:01,530
And here it has to be the plus and then here accordingly, the minus.

81
00:06:03,390 --> 00:06:03,900
OK.

82
00:06:04,290 --> 00:06:05,010
And.

83
00:06:06,950 --> 00:06:08,510
Was it the minus for this one?

84
00:06:08,540 --> 00:06:09,530
Yes, it was.

85
00:06:10,370 --> 00:06:18,020
OK, so now let me check because I believe I have this minus twice.

86
00:06:19,110 --> 00:06:20,430
OK, that's good to know.

87
00:06:20,970 --> 00:06:22,950
So let's use it instead here.

88
00:06:26,140 --> 00:06:30,940
Which creates a situation where this elusive would have been unnecessary.

89
00:06:31,300 --> 00:06:41,200
OK, let's run it again and 99 minus 66 and see, OK, we have only 33 now, not 30 3.0.

90
00:06:41,890 --> 00:06:42,220
All right.

91
00:06:42,340 --> 00:06:44,980
So that's pretty much it for this calculator.

92
00:06:44,980 --> 00:06:48,460
So you see, we have a proper calculator, we can clear the entry.

93
00:06:48,700 --> 00:06:53,770
Now, as you could, of course, have zero as the default value that is going to be displayed here if

94
00:06:53,770 --> 00:06:54,670
you wanted to.

95
00:06:54,940 --> 00:07:00,640
But overall, this is a calculator that works, at least for the basic operations.

96
00:07:01,900 --> 00:07:04,330
I hope you enjoyed this chapter in the next one.

97
00:07:04,330 --> 00:07:10,150
We're going to build an actually cool app because this was just to show you the fundamentals and really

98
00:07:10,150 --> 00:07:14,320
teach you how to use all of the good string stuff and the next chapter.

99
00:07:14,320 --> 00:07:16,960
We're actually going to build a cool quiz app, so see you there.

