Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,060 --> 00:00:04,340
So let's create our amazing intermediate mediate.
2
00:00:05,010 --> 00:00:07,600
Calculate her calculator.
3
00:00:07,950 --> 00:00:11,550
So for that, we are going to create two variables.
4
00:00:11,580 --> 00:00:13,010
The first one is number one.
5
00:00:13,440 --> 00:00:15,150
And the second one is number two.
6
00:00:15,300 --> 00:00:22,710
And also, we are going to create a variable to declare a variable of character, a type that will hold
7
00:00:22,850 --> 00:00:29,790
the mathematical operations sine that we are going to use that we are going to use up on these two numbers.
8
00:00:30,040 --> 00:00:30,870
One and two.
9
00:00:30,990 --> 00:00:34,710
So let's call a math operation math operation.
10
00:00:34,940 --> 00:00:38,150
And now we are going to print a nice message to the user.
11
00:00:38,190 --> 00:00:40,250
So print f enter.
12
00:00:40,380 --> 00:00:42,450
What math operation.
13
00:00:43,260 --> 00:00:44,130
Operation.
14
00:00:44,550 --> 00:00:47,520
You would like to use.
15
00:00:49,650 --> 00:00:59,220
So now the user will specify if it's either plus or minus and so on, plus minus and so on.
16
00:00:59,850 --> 00:01:00,200
Right.
17
00:01:00,240 --> 00:01:01,470
We have a couple of options.
18
00:01:01,480 --> 00:01:02,220
Five options.
19
00:01:02,250 --> 00:01:03,390
If I'm not mistaken.
20
00:01:05,040 --> 00:01:10,320
And now we are going to use the scanner function and we are the result using the percentage.
21
00:01:10,320 --> 00:01:13,680
See, because we are using a character.
22
00:01:13,710 --> 00:01:20,850
And we are going to write the result inside of math operation variable, which is of type char.
23
00:01:21,060 --> 00:01:24,910
Now, we are going also to read the two numbers from the user.
24
00:01:24,930 --> 00:01:27,450
So print f enter number one.
25
00:01:27,810 --> 00:01:32,180
Number one, we are going to release values.
26
00:01:32,250 --> 00:01:34,220
So scana f percentage.
27
00:01:34,230 --> 00:01:35,500
The percentage.
28
00:01:35,580 --> 00:01:37,440
The inside of No one.
29
00:01:38,880 --> 00:01:41,680
And we are going to do the same also for num two.
30
00:01:41,720 --> 00:01:44,000
So print f answer enter.
31
00:01:44,340 --> 00:01:50,270
Now to now to read the value for an on two percentage D.
32
00:01:50,730 --> 00:01:51,930
And number two.
33
00:01:52,470 --> 00:01:59,190
So at this point we have, we have the two numbers, the two numbers and the mathematical operation
34
00:01:59,220 --> 00:02:03,900
that we want to apply between to these two numbers.
35
00:02:04,350 --> 00:02:08,970
So now we should use one option was to use the EFL structure.
36
00:02:09,150 --> 00:02:11,520
But we are going to use this switch case.
37
00:02:11,790 --> 00:02:12,720
So switch.
38
00:02:13,830 --> 00:02:21,750
And after the switch inside of these parentheses, we specify the variable, the variable that we want
39
00:02:22,050 --> 00:02:22,590
to see.
40
00:02:22,590 --> 00:02:24,210
What cases can it hold?
41
00:02:24,330 --> 00:02:27,210
What cases can can it satisfy?
42
00:02:27,300 --> 00:02:31,800
So we just use the mass math operation variable here.
43
00:02:31,950 --> 00:02:38,820
And then we are going to open up these curly brackets and now we are going to specify the cases that
44
00:02:38,820 --> 00:02:41,520
this math operation variable can hold.
45
00:02:41,610 --> 00:02:46,230
So case number one is that these math operation holds a plus sign.
46
00:02:47,160 --> 00:02:51,230
And if that's the case, we are going to what we are going to do, guys.
47
00:02:51,690 --> 00:02:56,760
We are going to print out to print out the result of these math operation.
48
00:02:57,120 --> 00:03:05,010
So we are going to use percentage, the percentage see percentage, the percentage see and the percentage
49
00:03:05,010 --> 00:03:07,990
B equals to percentage B.
50
00:03:08,250 --> 00:03:09,440
And now I'll explain.
51
00:03:10,110 --> 00:03:10,740
So.
52
00:03:10,860 --> 00:03:14,610
So instead of the first percentage, we were just going to specify number one.
53
00:03:15,660 --> 00:03:21,600
And instead of the percentage C, we are going to specify the math operation.
54
00:03:21,690 --> 00:03:26,940
The math operation now two instead of the third one.
55
00:03:27,510 --> 00:03:32,040
So this part simply specifies what operation we are doing.
56
00:03:32,100 --> 00:03:33,370
So here will be No.
57
00:03:33,370 --> 00:03:33,780
One.
58
00:03:34,130 --> 00:03:36,060
The math operation and NUM two.
59
00:03:36,390 --> 00:03:39,450
And then we are also going to have the result in here.
60
00:03:39,750 --> 00:03:43,920
So the result in these cases just now, one plus number two.
61
00:03:44,160 --> 00:03:44,670
That's it.
62
00:03:44,760 --> 00:03:47,980
So just let's add also the brake line.
63
00:03:48,150 --> 00:03:49,200
The brake line.
64
00:03:49,420 --> 00:03:50,730
Hope you remember this one.
65
00:03:51,150 --> 00:03:52,110
So the brake line.
66
00:03:52,110 --> 00:03:58,950
And also we are going to move this guy a little bit and that's it for the case off of the plus sign.
67
00:03:59,070 --> 00:04:02,150
And also, we are going to do the same for the minus sign.
68
00:04:02,310 --> 00:04:03,450
So minus.
69
00:04:04,230 --> 00:04:07,260
And we are going to specify the single error commands.
70
00:04:07,530 --> 00:04:12,150
So let's just copy and paste this one and put it in here.
71
00:04:12,780 --> 00:04:17,370
So the only thing that is going to be changed here is just here.
72
00:04:17,370 --> 00:04:22,350
Instead of using the plus mathematical operation, we are going to use the minus.
73
00:04:22,470 --> 00:04:23,040
That's it.
74
00:04:23,130 --> 00:04:24,300
That's the whole difference.
75
00:04:24,840 --> 00:04:28,350
Also, we can do the same for multiplication sign.
76
00:04:28,770 --> 00:04:31,500
So we are going to do something like this.
77
00:04:31,560 --> 00:04:33,990
And to get it back here.
78
00:04:34,020 --> 00:04:36,360
Change it to multiplication.
79
00:04:36,530 --> 00:04:38,000
Here also.
80
00:04:38,300 --> 00:04:39,240
And there you go.
81
00:04:39,240 --> 00:04:41,640
You are done with another case.
82
00:04:41,760 --> 00:04:49,110
Now, what we are also interested in is to check out what will happen for the day vision operation.
83
00:04:49,200 --> 00:04:50,250
So if we have.
84
00:04:50,340 --> 00:04:58,140
So if we have another case where we specify that a vision between two numbers, then we are going to
85
00:04:58,290 --> 00:04:58,710
add.
86
00:04:58,970 --> 00:05:07,890
Now, their statement and we are going to ask if if Nam to name two equals to zero, then in this case
87
00:05:07,890 --> 00:05:15,600
we are going to print that you can not divide by zero one.
88
00:05:15,690 --> 00:05:16,040
Right.
89
00:05:16,140 --> 00:05:21,240
Which is which is a good message that will help our program not to crash.
90
00:05:21,540 --> 00:05:28,560
And else if NAM two does not equal to zero meaning we are okay, we can do their division operation.
91
00:05:28,830 --> 00:05:35,040
We are going to use the similar printf command that we've used previously in the previous cases.
92
00:05:35,130 --> 00:05:43,370
So just copy and paste, copy and paste and instead of multiplication, we are going to use the equation.
93
00:05:43,710 --> 00:05:45,450
So I hope you got the idea.
94
00:05:45,540 --> 00:05:54,120
And similarly, we can do also for the last mathematical operation, which is to find out the remainder.
95
00:05:54,150 --> 00:05:56,280
So you just remove it.
96
00:05:56,430 --> 00:05:59,820
And here, instead of these division, we use this one.
97
00:05:59,940 --> 00:06:02,250
And basically, there you go.
98
00:06:02,370 --> 00:06:08,100
We just need to also to add the default section, the default, the default section.
99
00:06:08,490 --> 00:06:15,000
And if that's the case, if we if the user didn't specify any one of these mathematical operations,
100
00:06:15,390 --> 00:06:19,770
then the default will be would be just to print him that.
101
00:06:20,970 --> 00:06:21,420
I don't know.
102
00:06:21,430 --> 00:06:22,400
Something like that.
103
00:06:22,440 --> 00:06:23,040
Wrong.
104
00:06:23,550 --> 00:06:26,970
Mathematical operation.
105
00:06:27,600 --> 00:06:28,240
Try again.
106
00:06:28,980 --> 00:06:29,580
Try again.
107
00:06:29,850 --> 00:06:30,360
All right.
108
00:06:30,960 --> 00:06:31,380
Backslash.
109
00:06:31,470 --> 00:06:37,500
And at the end, you get one line down and they say, my call and let's just use it for is a default.
110
00:06:37,770 --> 00:06:38,100
All right.
111
00:06:38,110 --> 00:06:38,610
The break.
112
00:06:38,700 --> 00:06:41,080
So I think we are good.
113
00:06:41,220 --> 00:06:45,420
Let's just reduce it a little bit and see the whole structure of it.
114
00:06:45,570 --> 00:06:52,890
So we've created a couple of cases that check out if the value and they check out the value of the --
115
00:06:52,890 --> 00:06:54,180
operation variable.
116
00:06:54,450 --> 00:07:00,840
And based on the result of these -- operation, we are going to print a corresponding message just
117
00:07:00,840 --> 00:07:07,230
just like a real calculator, just like a real calculator, or you specify the numbers you want to to
118
00:07:07,230 --> 00:07:09,840
calculate in the mathematical operation.
119
00:07:10,020 --> 00:07:13,380
And the calculator will give you your results.
120
00:07:14,280 --> 00:07:17,400
So let's try to build and run it and see what happens.
121
00:07:17,490 --> 00:07:22,110
First of all, we are going to increase the console application window and.
122
00:07:22,320 --> 00:07:22,770
All right.
123
00:07:22,860 --> 00:07:25,060
Enter what math operation you would like to use.
124
00:07:25,080 --> 00:07:27,210
Let's say we would like to use the glass.
125
00:07:27,540 --> 00:07:27,990
All right.
126
00:07:28,020 --> 00:07:29,820
Plus, enter name one.
127
00:07:29,850 --> 00:07:30,700
So five.
128
00:07:30,720 --> 00:07:32,250
And number two is seven.
129
00:07:32,610 --> 00:07:38,320
And if we press enter, we hope to see that the result is just twelve.
130
00:07:38,730 --> 00:07:41,820
So five plus seven equals twelve.
131
00:07:41,860 --> 00:07:44,160
And that's exactly what we expected to see.
132
00:07:44,820 --> 00:07:48,580
So this is it for these milestone guys.
133
00:07:48,600 --> 00:07:52,620
And you see the progress that you've made so far, how much you improved.
134
00:07:52,630 --> 00:07:53,020
Right.
135
00:07:53,370 --> 00:07:59,670
I think that you can feel it, that the improvement is being very, very good on your side.
136
00:08:00,150 --> 00:08:05,490
And you can also extend this calculator even one step further.
137
00:08:05,520 --> 00:08:09,130
That's why we use the switch cases structure.
138
00:08:09,570 --> 00:08:15,360
Because now, if we want to add another mathematical operation, we just can use another case.
139
00:08:15,430 --> 00:08:16,830
Add here another case.
140
00:08:16,890 --> 00:08:19,370
Case, another mathematical operation.
141
00:08:19,380 --> 00:08:21,000
I don't know, maybe something like.
142
00:08:21,380 --> 00:08:22,170
Like that.
143
00:08:23,010 --> 00:08:24,210
Like this one.
144
00:08:24,780 --> 00:08:25,170
All right.
145
00:08:25,680 --> 00:08:32,160
And then we specify the commands and the mathematical operation that should be done and what they are.
146
00:08:32,520 --> 00:08:35,460
What message should be printed on a screen in such a case?
147
00:08:36,540 --> 00:08:38,250
So thank you guys for watching.
148
00:08:38,310 --> 00:08:41,040
Thank you guys for trying to do your best.
149
00:08:41,320 --> 00:08:47,010
And I'll see you in the next video, which is probably going to be in the next section.
12533
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.