Day 8


 Hello!

Today we continue the Java course that we started on October 9th

.Let's start

Today I learned something that is not new, it is like if condition, but it is more organized and less .complicated than if condition and very simple, which is switch

I will show you a screenshot of a few lines that I wrote after I took the course and explain it to you, it will be better


As we can see in line 6, VariableGrate was defined

And if you are facing some problems in line 9, no problem, it will be explained in detail because it is not the time now

In line 10, the switch function was called to use it

Line 11 is the beginning of the code and it is the place of if and its function is if the letter A is entered, it will print excellant

When the letter B is entered, it prints very good, and this is the function of line 15 and so on in the rest of the lines

Of course, we will not use all the letters, so we will specify the letters representing lines 12, 15, 18, 21, 24. However, if we enter any other letter that we did not write in the case, then using the default command, such as line 27, it will print a message in the output from our writing, for example, Error. Of course, you noticed a word repeated as many times as any line containing the case, which is break. I did not neglect it, I left it at the end to explain it better because of its great importance. If we do not put it, both commands will appear on the output together. For example, if the word break is deleted in line 14, it will appear on the output, excellent, and the command that follows it, which is very good, and it will continue until it finds the word break and stops. It is very important and we must never forget it.

تعليقات

المشاركات الشائعة