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
Mark Colvin.
What is going on, guys?
So let's get down to business right away.
We need to create three great variables, grade one grade, too, and grade three.
So for that, we'll use in grade one.
Great.
Two and grade in grade three.
Semicolon at the end.
Control, as we say.
Now, let's print some nice message in which we will ask the user to insert its first grade.
So we'll use something like print F, enter grade one.
And now let's read grade one from the user and put this value inside of variable grade one so we can
do it by using scan F, scan F percentage.
The because we are using we are reading an integer value and we will place it inside of the address
where grade one resides.
All right.
This is good.
Now let's do the same for both the grade two and grade three.
OK.
So copy paste and copy paste.
Print F, enter a grade two and the same here.
Great.
Two in here will enter a grade three and read the grade three.
There you go.
Also, let's define here another variable called average.
And we will set it to be of type double.
So use double average.
This variable should hold the average of the three grades we've just read from the user.
All right.
So at this point, we can basically say that the average of the previous three grades read here on this
line of where we used scan F, the average should be something like that.
Average equals two.
Let's some all of the grades.
So grade one plus.
Grade two plus.
Grade three.
Right.
And just divided by three.
Semicolon at the end.
And now let's think will it work?
I want you to pause the video and take a second to think about it.
So the answer to this question is absolutely no.
Because we've just talked about how important it is to use casting.
To get the exact grade, assuming it may maybe a floating point type.
And we've learned a couple of ways in which we can accomplish that.
So in this example, we can see that on the right side of the equation in line 14.
You can see that both the participants on the right side here.
Right.
Here is the three end.
Also, all of these some both of them are basically integers.
And we know that the result of these mathematical operation, we've said it previously in there in the
video where we discussed casting, the result of that is also going to be of type in nature, meaning
that if we get here on the right side, an average grade of something like eighty five point seven,
if we should get this value, basically it will be just rounded to eighty five.
And then we lose the whole point of using these exercises.
So for that, we need to use casting.
And basically we should simply define one of these.
Or a numerator or denominator to be of type of type double or a floating point type, for example.
So the easiest way to do it when we can simply just add a dot zero at the end.
And what we've basically done here is we simply say that these value, instead of using three, as it
was previously, just an integer, that this value is of ways of a floating point.
And this means that the result of this whole operation, of this whole day vision, of this sum by these
three point zero, the result of eating is also going to be by default.
It's also going to be of a floating point type.
And that's exactly what we want to do.
So let's now print the result, print the average grade.
So print F average equals two percentage left because we use double.
Actually, there is no real Nessus.
Nicest necessity to use double here.
We can basically just use float.
But let's leave it as is for now.
And here we will use the average semicolon at the end here.
All right.
Now let's build and run it.
Oh, and we have a little problem here.
Was the problem in line 14 average equals to grade one plus grade two plus rate.
Oh, I forgot the three here divided by three point zero.
All right.
So now it should be good.
Let's save it and build and run it once again.
There you go.
Here is our consular application.
Now, let's use some example here.
Let's say it was the first.
Wade was 80 and then we had 60.
Then we had, I don't know, ninety five.
So every time you pressed enter, I just just to remind you guys, the number itself you pressed here
was inserted, was placed inside of the corresponding variable.
So in this example we had one and then grey two and then grade three once we pressed the enter right
now.
So let's press that.
And there and there you go.
There is your average grade equals to seventy eight point three three three.
We can limit that by placing here DOT two.
And also, of course, let's add a backslash in the end just to separate separated from the default
text.
Let's build in running once again executes something like 75, 65 and 200.
Let's do it like 97.
Larry, go seventy nine point zero zero.
We'll limited it by putting a DOT two, which simply says you can place just two digits after the floating
point.
All right.
So we almost finished this exercise.
Just one last thing that I want to show you guys in this example.
We can also leave the three, as it was previously, as an integer, and instead we can just think any
of these variables here on the left side.
We can take any of them and just cast them to be of type double.
This basically will be enough for for the whole operation, for the whole math operation to treat it
as a floating point number so we can basically do something like that.
Just add here double casting and now all of your result will be treated as a floating point and it will
work okay without any round to the smallest integer.
You can also do the same for the second for the OP's.
Sorry about that.
There you go.
You can also do it for the second grade.
It doesn't matter.
Okay.
So basically, I hope you've got the idea of how to use casting and you practice it with this nice little
exercise of using three grades.
And actually, yeah, I can say that I think that you're ready to move on to your next milestone.
And actually, the next milestone is very interesting milestone because you will develop in this milestone
a weather station.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.