Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So let's create our amazing intermediate mediate.
Calculate her calculator.
So for that, we are going to create two variables.
The first one is number one.
And the second one is number two.
And also, we are going to create a variable to declare a variable of character, a type that will hold
the mathematical operations sine that we are going to use that we are going to use up on these two numbers.
One and two.
So let's call a math operation math operation.
And now we are going to print a nice message to the user.
So print f enter.
What math operation.
Operation.
You would like to use.
So now the user will specify if it's either plus or minus and so on, plus minus and so on.
Right.
We have a couple of options.
Five options.
If I'm not mistaken.
And now we are going to use the scanner function and we are the result using the percentage.
See, because we are using a character.
And we are going to write the result inside of math operation variable, which is of type char.
Now, we are going also to read the two numbers from the user.
So print f enter number one.
Number one, we are going to release values.
So scana f percentage.
The percentage.
The inside of No one.
And we are going to do the same also for num two.
So print f answer enter.
Now to now to read the value for an on two percentage D.
And number two.
So at this point we have, we have the two numbers, the two numbers and the mathematical operation
that we want to apply between to these two numbers.
So now we should use one option was to use the EFL structure.
But we are going to use this switch case.
So switch.
And after the switch inside of these parentheses, we specify the variable, the variable that we want
to see.
What cases can it hold?
What cases can can it satisfy?
So we just use the mass math operation variable here.
And then we are going to open up these curly brackets and now we are going to specify the cases that
this math operation variable can hold.
So case number one is that these math operation holds a plus sign.
And if that's the case, we are going to what we are going to do, guys.
We are going to print out to print out the result of these math operation.
So we are going to use percentage, the percentage see percentage, the percentage see and the percentage
B equals to percentage B.
And now I'll explain.
So.
So instead of the first percentage, we were just going to specify number one.
And instead of the percentage C, we are going to specify the math operation.
The math operation now two instead of the third one.
So this part simply specifies what operation we are doing.
So here will be No.
One.
The math operation and NUM two.
And then we are also going to have the result in here.
So the result in these cases just now, one plus number two.
That's it.
So just let's add also the brake line.
The brake line.
Hope you remember this one.
So the brake line.
And also we are going to move this guy a little bit and that's it for the case off of the plus sign.
And also, we are going to do the same for the minus sign.
So minus.
And we are going to specify the single error commands.
So let's just copy and paste this one and put it in here.
So the only thing that is going to be changed here is just here.
Instead of using the plus mathematical operation, we are going to use the minus.
That's it.
That's the whole difference.
Also, we can do the same for multiplication sign.
So we are going to do something like this.
And to get it back here.
Change it to multiplication.
Here also.
And there you go.
You are done with another case.
Now, what we are also interested in is to check out what will happen for the day vision operation.
So if we have.
So if we have another case where we specify that a vision between two numbers, then we are going to
add.
Now, their statement and we are going to ask if if Nam to name two equals to zero, then in this case
we are going to print that you can not divide by zero one.
Right.
Which is which is a good message that will help our program not to crash.
And else if NAM two does not equal to zero meaning we are okay, we can do their division operation.
We are going to use the similar printf command that we've used previously in the previous cases.
So just copy and paste, copy and paste and instead of multiplication, we are going to use the equation.
So I hope you got the idea.
And similarly, we can do also for the last mathematical operation, which is to find out the remainder.
So you just remove it.
And here, instead of these division, we use this one.
And basically, there you go.
We just need to also to add the default section, the default, the default section.
And if that's the case, if we if the user didn't specify any one of these mathematical operations,
then the default will be would be just to print him that.
I don't know.
Something like that.
Wrong.
Mathematical operation.
Try again.
Try again.
All right.
Backslash.
And at the end, you get one line down and they say, my call and let's just use it for is a default.
All right.
The break.
So I think we are good.
Let's just reduce it a little bit and see the whole structure of it.
So we've created a couple of cases that check out if the value and they check out the value of the --
operation variable.
And based on the result of these -- operation, we are going to print a corresponding message just
just like a real calculator, just like a real calculator, or you specify the numbers you want to to
calculate in the mathematical operation.
And the calculator will give you your results.
So let's try to build and run it and see what happens.
First of all, we are going to increase the console application window and.
All right.
Enter what math operation you would like to use.
Let's say we would like to use the glass.
All right.
Plus, enter name one.
So five.
And number two is seven.
And if we press enter, we hope to see that the result is just twelve.
So five plus seven equals twelve.
And that's exactly what we expected to see.
So this is it for these milestone guys.
And you see the progress that you've made so far, how much you improved.
Right.
I think that you can feel it, that the improvement is being very, very good on your side.
And you can also extend this calculator even one step further.
That's why we use the switch cases structure.
Because now, if we want to add another mathematical operation, we just can use another case.
Add here another case.
Case, another mathematical operation.
I don't know, maybe something like.
Like that.
Like this one.
All right.
And then we specify the commands and the mathematical operation that should be done and what they are.
What message should be printed on a screen in such a case?
So thank you guys for watching.
Thank you guys for trying to do your best.
And I'll see you in the next video, which is probably going to be in the next section.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.